5 Replies Latest reply on Nov 11, 2008 8:33 PM by nagarjunaakkineni

    Combobox with XML

    Level 1

      Hi All,
      " I have one External XML file and one MXML application".The XML file contains Group of elements.
      How to get the data from External XML file and display in Combobox.

      Here i'm sending files also.....

      My XML file is like this...

      category.xml
      <CategoryList>
      <CategoryListitems>
      <categoryname>Home</categoryname>
      <description>Tasks realted to Home</description>
      </CategoryListitems>
      <CategoryListitems>
      <categoryname>Office</categoryname>
      <description>Tasks realted to Office</description>
      </CategoryListitems>
      <CategoryListitems>
      <categoryname>Personal</categoryname>
      <description>Tasks realted to Personal</description>
      </CategoryListitems>
      <CategoryListitems>
      <categoryname>Sports</categoryname>
      <description>Tasks related to Sports</description>
      </CategoryListitems>
      </CategoryList>

      My MXML file like this ...........

      <mx:Application
      xmlns:mx=" http://www.adobe.com/2006/mxml"
      width="100%" height="100%">
      <mx:HTTPService id="getcategory" url="category.xml"/>
      <mx:ComboBox id="deltaskstatus" dataProvider="{getcategory.lastResult.CategoryList.CategoryListitems}"/>
      </mx:Application>


      Can u tel me please.........

      How to display the data in the Combobox after getting data from External XML file...

      Thanks in advance,
      nagarjuna.
        • 1. Re: Combobox with XML
          m_hartnett Level 3
          There are a few different ways to do this, heres one:

          dataProvider="{getcategory.lastResult.children()}" labelField="description"/>
          • 2. Re: Combobox with XML
            Level 1
            hi wingobaxter ,
            Data is came to the Combobox but how to get the data from combobox.I tried to get the data but it is showing value as [object object]. I need to store the data into the database after getting the data from the combobox.

            How to get that data please tel me............

            Thanks in advance.
            • 3. Re: Combobox with XML
              Gregory Lafrance Level 6
              myComboBox.selectedItem
              or
              myComboBox.selectedLabel
              • 4. Re: Combobox with XML
                m_hartnett Level 3
                The data is being stored as an XML object with the following form:
                <CategoryListitems>
                <categoryname>Home</categoryname>
                <description>Tasks realted to Home</description>
                </CategoryListitems>

                so the selectedItem attribute is an object. You need to get your values from the Object. There are a few ways to do it:

                var obj : Object = deltaskstatus.selectedItem;
                var catName : String = obj.categoryname;
                var desc : String = obj.description;


                • 5. Re: Combobox with XML
                  Level 1
                  hi wingobaxter ,
                  First i want to store data in Model object and then i need to send the request to jsp then that data store into the database.

                  this is my model ...

                  <mx:Model id="addData">
                  <root>
                  <taskcategory>{taskcategory.seletedItem}</taskcategory>
                  </root>
                  </mx:Model>

                  If i use "taskcategory.text" Prompttext also coming when i didn't select anything......

                  Wt is the solution for that.......

                  Thanks in advance,
                  nagarjuna.