2 Replies Latest reply on May 16, 2011 9:32 AM by 5Systems

    drop down List dataProvider and a Value Object

    5Systems Level 1

      I am trying to populate a drop down list with values that are held within a value object.   I am pulling table values from an SQLite database vai the SQLResult object and they are comming in as an array of Value Objects. this is exaclty What I want so I reference those within a property of my Model Object and dispatch and event carrying that array.   I place the array of Value objects into an array collection like so:

       

      var dropDownListValues:ArrayCollection = new ArrayCollection(event.foodCategoryList);
      

       

      Then try to access them via a dropdown lists dataProvider property like so:

       

      foodCategory.FoodCategory_DropDown.dataProvider = dropDownListValues;
      

       

       

      My dropdown then displays

       

      [object Object]
      [object Object]
      [object Object]
      [object Object]
      [object Object]
      [object Object]
      

       

      My dropDownListValues object carries the following array:

       

      [0]
           Foodcatagory = "Grains"
           FoodCatagory_ID = 1
      
      [1]
           Foodcatagory = "Vegetables"
           FoodCatagory_ID = 2
      
      
      
      
      etc. all the way up to index 5
      
      
      

       

       

      How do I get the Dropdown list to display just  Grains, Vegetables ..... etc. ?

       

      Thanks,

        • 1. Re: drop down List dataProvider and a Value Object
          da-juice

          I had to search around for a couple of hours today on the same issue.

           

          Basically just set the labelField of the dropdown to be the name of the field for its values

           

          foodCategory.FoodCategory_DropDown.labelField = "Foodcatagory";
          
          • 2. Re: drop down List dataProvider and a Value Object
            5Systems Level 1

            Da-juice,

             

             

             

            Thanks, you answer was quite helpful, I appreciate it very much.  I had used a loop to temporarily solve the problem, but I knew there had to be a more elegant solution.

             

             

            just for clarification for those who may find this post in the future, here is the final code snippet that got it to work based on Da-juice replay.

             

            var dropDownListValues:ArrayCollection = new ArrayCollection(event.foodCategoryList); //Pull from event payload
            foodCategory.FoodCategory_DropDown.dataProvider = dropDownListValues; // Place event payload data into the dropdowns dataProvider
            foodCategory.FoodCategory_DropDown.labelField = "Foodcatagory"; //Set label Property to match that of the Value objects poperty.