0 Replies Latest reply on Apr 29, 2010 8:15 AM by RandomReado

    valueField for DropDownList control?

    RandomReado Level 1

      I have some XML as follows:

       

      <xml>
        <user name="A" id="1"/>
        <user name="B" id="2"/>
        <user name="C" id="3"/>
        <user name="D" id="4"/>
        <user name="E" id="5"/>
      </xml>
      

       

      Here's the AS that processes the XML (part of an HTTPService result handler):

       

      var xml:XML = event.result as XML;
      var user:XMLListCollection = new XMLListCollection(xml.user);
      user.source = xml.children();
      userList.dataProvider = user;

       

      The MXML drop down control:

       

      <s:DropDownList id="userList"
      labelField="@name"
      change="trace(userList.selectedItem.value)"
      width="500"/>
      

       

      In Flex I have set the labelField to @name, run the application and the drop down list appears as expected. However I now need to specify the custom value field as @id. Flex says valueField does not exist when I try to add it to the DropDownList control. Even if I set "id" to "value" in the XML and try again, it still doesn't work. I'm using trace to show what the value when we select a user from the list, which returns a blank result for each item selected.

       

      Any idea how I can bind the value field "id" to the drop down? Thanks in advance.