1 Reply Latest reply on Aug 10, 2009 11:31 AM by Kenny Yates

    Question about loading array of custom objects into a datagrid control.

    vindictive27 Level 1

      Overview:

       

      I've created two custom objects, for example:

       

      Sandwich object - contains name of sandwich as a string, and an array of Toppings objects.

       

      Toppings object - contains 2 strings, the name of the topping and the amount of topping used.  They have to stay together.

       

      Problem:

       

      In my main MXML file, I want to populate 2 controls - a label above a datagrid, and the datagrid itself.

       

      The label gets the sandwich name string from the sandwich object and displays the name, no problem.

       

      I try to wrap the toppings array in an arraycollection and use it as the dataprovider for the grid - with the idea that the two columns of the grid will list a) the topping name, and b) the amount of topping used.

       

      However, the problem is that since I'm returning an array of Toppings objects - Flex doesn't really have any idea what those are at this level (just that they are Toppings objects, not specifically a Toppings object with ketchup and 3oz as elements I can access).  I have getters and setters in the Toppings object - but I can't seem to drill down to those.  So the grid remains empty.

       

      Question:

       

      How can I ultimately bring through the two elements of the Toppings objects - each their own column in the datagrid (while remaining linked together)?  Or should I be using another control completely for this task?

       

      Thank you!!!

      Mike