0 Replies Latest reply on Nov 24, 2008 2:20 AM by premadas

    Combobox

    premadas

      Hi All,
      I have two comboboxes.I'm getting the data from XML file.Xml file contains "Home,Office,Sports,Personal" values are there.

      For one combobox i want to display the content of xml file and for other combobox i need to diplay the xml file content and i want to add another element i.e "All".

      I tried but "All" element is coming both comboboxes.

      How to do that...
      Here am sending my code.Can u rectify the code.

      MXML file...

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" creationComplete="cate.send();">

      <mx:Script>
      <![CDATA[
      import mx.collections.ArrayCollection;
      import mx.rpc.events.ResultEvent;

      [Bindable]
      public var arr:ArrayCollection;

      [Bindable]
      public var arr1:ArrayCollection;

      private function resultHandler(event:ResultEvent):void
      {
      /* arr = new ArrayCollection();
      arr = event.result.categorylist.categoryitems;
      firstcategory.dataProvider = arr; */
      arr1 = new ArrayCollection();
      arr1 = event.result.categorylist.categoryitems;
      arr1.addItemAt(({categoryname:'All'}),0);
      secondcategory.dataProvider = arr1;
      }

      ]]>
      </mx:Script>

      <mx:HTTPService id="cate" url="Combo.xml" result="resultHandler(event);"/>
      <mx:Panel width="100%" height="100%">
      <mx:ComboBox id="firstcategory" dataProvider="{cate.lastResult.categorylist.categoryitems}" labelField="categoryname"/>
      <mx:ComboBox id="secondcategory" labelField="categoryname"/>
      </mx:Panel>
      </mx:Application>


      XML file
      <?xml version="1.0" encoding="UTF-8"?>
      <categorylist>
      <categoryitems>
      <categoryname>Home</categoryname>
      </categoryitems>
      <categoryitems>
      <categoryname>Office</categoryname>
      </categoryitems>
      <categoryitems>
      <categoryname>Sports</categoryname>
      </categoryitems>
      <categoryitems>
      <categoryname>Personal</categoryname>
      </categoryitems>
      </categorylist>

      Thanks in Advance,
      Premadas.