1 Reply Latest reply on Nov 4, 2009 1:07 AM by paul.williams

    problem getting the selecteditem in tree while fetching data through httpserivces

    Chintal08

      I have a mxml file in which a want to display data in tree structure. The supplied to the tree is fetched from database through httpservice

       

      the mxml file content is :

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

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

      <mx:Application

       

       

      xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete ="getMenu.send();"

      >

       

       

       

      <mx:HTTPService

      id="

       

      getMenu

      "

      method="

       

      GET

      "

      url="

       

      http://172.17.26.55:7001/frmwk/MenuData

      "

      resultFormat="

       

      e4x

      "

      result="resultHandler(event)"

      useProxy="

       

      false

      "

       

       

      />

       

       

      <mx:Script>

      <![CDATA[

       

       

      import

      mx.controls.Alert;

       

       

      import

      mx.rpc.events.FaultEvent;

       

       

      import

      mx.rpc.events.ResultEvent;

       

       

      import

      mx.collections.XMLListCollection;

       

       

      import

      mx.events.CloseEvent;

       

       

       

       

      private var companyData:XML = new

      XML;

       

       

      private var

      Menu:XMLListCollection;

       

       

       

      private function resultHandler(event:ResultEvent):void

      {

       

      companyData = event.result

       

      as

      XML;

      Menu =

       

      new

      XMLListCollection(companyData.MENU);

      tree.dataProvider=Menu;

      }

       

       

       

      private function getSelected():void

      {

       

      Alert.show(

       

      "selected--->"

      +tree.selectedItem);

      }

       

       

      ]]>

       

       

      </mx:Script>

       

       

      <mx:Label text="Tree with XML data"

      />

       

       

       

      <mx:Tree id="tree" top="100" left="400" labelField="@title" height="224" width="179

      "

      dragEnabled="

       

      false" dropEnabled="false" allowMultipleSelection="true

      "

       

       

      />

       

       

      <mx:Button label="get Selected item" click="getSelected()" x="400" y="450"

      />

       

       

      When i try to get the selected item is is giving me null

       

      Please help !!

       

      thanks in advance.