0 Replies Latest reply on Aug 2, 2011 1:52 PM by Mr Nitin

    how to change the data provider of the tree with the selection of combobox

    Mr Nitin

      This is my XML data in a file named `nodesAndStuff.xml`.


          <?xml version="1.0" encoding="utf-8"?>
              <node label="One" />
              <node label="Two" />
              <node label="Three" />
              <node label="Four" />
              <node label="Five" />
              <node label="Six" />
              <node label="Seven" />
              <node label="Eight" />
              <node label="Nine" />

      The component using this data source is an `XMLListCollection` which is bound to a spark `ComboBox` and the code for that is:


          <s:Application name="Spark_List_dataProvider_XML_test"


                  private function init():void {
                      xmlListColl.source = nodes.children();

      private function closeHandler(event:Event):void {
                      myLabel.text = "You selected: " +  ComboBox(event.target).selectedItem.label;                 myData.text = "Data: " +  ComboBox(event.target).selectedItem.data;


              <fx:XML id="nodes" source="nodesAndStuff.xml" />


          <mx:ComboBox id="cmbList" dataProvider="{ListXLC}" labelField="STOREVALUE"  close="closeHandler(event);"/>

      <s:XMLListCollection id="xmlListColl" />


      <mx:VBox width="250" color="0x000000">
                  <mx:Text  width="200" color="blue" text="Select a type of credit card."/>
                  <mx:Label id="myLabel" text="You selected:"/>
                  <mx:Label id="myData" text="Data:"/>


      <mx:Tree id="myTree" width="50%" height="100%" visible="false" />



      now another of my xml for example this is one.xml


      <?xml version="1.0" encoding="utf-8"?>
      <node label="Eleven" />
      <node label="Twelve" />
      <node label="Thirteen" />
      <node label="Fourteen" />
      <node label="Fifteen" />
      <node label="Sixteen" />
      <node label="Seventeen" />
      <node label="Eightteen" />
      <node label="Nineteen" />

      and another one is two.xml


      <?xml version="1.0" encoding="utf-8"?>
      <node label="twety one" />
      <node label="twety two" />
      <node label="twety three" />
      <node label="twety four" />
      <node label="twety five" />
      <node label="twety six" />
      <node label="twety seven" />
      <node label="twety eight" />
      <node label="twety nine" />


      Now I have added my tree just below the list and I have saved counting from 10 to 19 in `one.xml`, 20 to 29 in `two.xml` and so on in different XML file. I have no clue how to connect the XML containing counting from 10 to 19 as the single node in tree at the selection of label one in list and make its visiblity true.this all are dependent on combobox as on selection of item in combobox will lead to change the dataprovider of tree at runtime. i.e on selecting value one in combobox one.xml should be the data provider for tree control. Can anyone help me on this