3 Replies Latest reply on Mar 2, 2014 10:47 PM by Flex harUI

    DataGrid with two types


      Hey Guys

      I have a little problem with which I hope you can help me.


      I have a DataGrid which I'm trying to fill with Objects from different types.




      I have several objects:


      Human (Origin Class)

      Customer (Child from Human)

      Supplier (Child from Human)

      Animal (Origin ClasS)

      Cat (Child from Animal)

      Dog (Child from Animal)


      So it's no problem to put the customers and the suppliers together in the DataGrid, or the cats and the dogs. (Because of the heredity).


      But because I have to define the type during the initiation I can not put humans and animals together in one DataGrid.


      Is there a posibility to initiate the DataGrid with two types?


      Or does someone know an other solution?


      Thanks in advance



        • 1. Re: DataGrid with two types
          Flex harUI Adobe Employee

          Create a base class called "Thing" and have all classes derive from it.


          Which DataGrid are you using (Spark or MX)?  What error do you get with a mixed data provider?



          • 2. Re: DataGrid with two types
            Jochen89 Level 1


            First, thank you for the help. I later had the same idea with the base class. Know there is some problem with the database. But that's an other problem.


            So thanks for your help!


            Actually I'm not sure which DataGrid I'm using. I'm quite sure it's not MX, Because I can't find any MX-Code. The DataGrid gets created with a function in its own class. (EntityDataGrid.as)


            I do not get any error. The other objects just don't get viewed. (There is an exception rule)


            - Jochen89

            • 3. Re: DataGrid with two types
              Flex harUI Adobe Employee

              Sounds like  a custom data grid.  But I would expect it to "extend" one of the Flex data grids.


              You should be able to have mixed types as long as they have the same properties as specified by the columns, or you specify labelFunctions.