1 Reply Latest reply on Feb 13, 2010 7:09 AM by Gregory Lafrance

    Adding icons to a tree with an external xml as its data provider

    RonnieCR7 Level 1

      Hi All,

      I wanna add icons to my tree. It takes an external XML as its data provider. The structure of the XML is something like this:

      <A>

      <B>

      <C><1></1></C>

      <C><2></2></C>

      <C><3></3></C>

      </C>

      </B>

      <B>

      <C>

      <D><2></2></D>

      <D><2></2></D>

      <D><3></3></D>

      </C>

      </B>

      </A>

       

       

      Here i wanna assing different icons to different tags(A, B, C, D)

      I know that by using defaultLeafIcon property in mx:Tree we can set an icon to the leaves. But i wanna set different icons to different nodes.

      As u see in the above example, some leaves are C, while some are D. I should able to differentiate between them as well.

      Any suggestions?

        • 1. Re: Adding icons to a tree with an external xml as its data provider
          Gregory Lafrance Level 6

          You could try using the iconFunction property to specify a method to determine the icon:

           

          iconFunctionproperty

          iconFunction:Function  [read-write]

           

           

          A user-supplied function to run on each item to determine its icon. By default the list does not try to display icons with the text in the rows. However, by specifying an icon function, you can specify a Class for a graphic that will be created and displayed as an icon in the row. This property is ignored by DataGrid.

          The iconFunction takes a single argument which is the item in the data provider and returns a Class.

           

          The default value is null

          This property can be used as the source for data binding.


          Implementation
              public function get iconFunction():Function
              public function set iconFunction(value:Function):void

           

          If this post answers your question or helps, please mark it as such.


          Greg Lafrance - Flex 2 and 3 ACE certified

          www.ChikaraDev.com

          Flex / AIR Development, Training, and Support Services
           

          1 person found this helpful