Skip navigation
Currently Being Moderated

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

Dec 10, 2012 4:38 AM

Tags: #xml #tree #node #labelfunction #leaf

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

 

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points