0 Replies Latest reply on Mar 18, 2011 5:31 AM by nbaztec

    Add items to DropDownList using ItemRenderer


      I have a XML structure like:


          <Data Name="Data1">
          <Data Name="Data2">


      I use a custom DropDownList to populate it using an ItemRendererFunction:

      <s:Label text="{data.attribute('Name')}" top="3" left="10" right="10" bottom="3" color="0xFF00FF" />

      if it has an attribute 'Name', else a regular Label.

      Render function is :

      public function renderNode(item:*):IFactory
          if (item.attribute('Name') != null)
              return new ClassFactory(SpecialItemRenderer);
              return new ClassFactory(RegularItemRenderer);


      However, I specify the XML in the form of a dataProvider, as dProv.child('Category1'), hence I only get the 2 <Data> nodes in the renderNode(). But I also want to populate the <Item> nodes at the same time.

      I've tried using a loop using a new itemRendererFunction


        var nodes:XMLNode = item.children();
            nodes = nodes.nextSibling;
      but got a runtime error as the newFunc() wouldn't be returning anything.



      Then I made changes to the original renderNode() by creating a mx:Label item dynamically & adding it

      to this via this.addElement(newLabel) but this wouldn't place the Label in the drop down list, but on top of the control.


      So I'd like to know is there any way I can add these Items/label dynamically while parsing the original XML Data?


      Nisheeth Barthwal