0 Replies Latest reply on Dec 10, 2012 4:38 AM by Supreet R

    Xml parsing in <mx:Tree> component - Data is not displayed in leaf node.

    Supreet R

      Dear All,

       

      I have a xml with employee details, when i pass this xml as dataprovider to mx tree component and set the label function,

      It doesnt displays the data in the leaf node.

       

      The code is as shown below,

       

      <?xml version="1.0" encoding="utf-8"?>

      <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"

                             xmlns:s="library://ns.adobe.com/flex/spark"

                             xmlns:mx="library://ns.adobe.com/flex/mx">

          <fx:Declarations>

              <fx:XML id="emp">

                  <employees>

                      <employee>

                          <ssn>123-123-1234</ssn>

                          <name>

                              <first>John</first>

                              <last>Doe</last>

                          </name>

                          <address>

                              <street>11 Main St.</street>

                              <city>San Francisco</city>

                              <state>CA</state>

                              <zip>98765</zip>

                          </address>

                      </employee>

                  </employees>

              </fx:XML>

          </fx:Declarations>

         

          <fx:Script>

              <![CDATA[

                  private function getTreeLabel(item:XML):String

                  {

                      return item.name();

                  }

              ]]>

          </fx:Script>

         

          <mx:Tree id="tree" width="300" height="500"

                   dataProvider="{emp}"

                   labelFunction="getTreeLabel"/>

      </s:WindowedApplication>

       

      How to display the data(leaf node data) properly in the mx tree component ??

       

      TreeGetByTag_2012-12-10_17-40-54.png

       

      Thanks,

      Supreet R