Combo box populate from xml

Ask a Question related to Macromedia Flex General Discussion, Design and Development.

  1. #1

    Default Combo box populate from xml

    Hi.

    Is it possible to publish an example that shows how populate a combobox with a
    xml file?

    For example, if you have this xml:

    var sample : XML =
    <Values>
    <Value>
    <Label>20 per page</Label>
    <NumberPerPage>20</NumberPerPage>
    </Value>
    <Value>
    <Label>50 per page</Label>
    <NumberPerPage>50</NumberPerPage>
    </Value>
    <Value>
    <Label>100 per page</Label>
    <NumberPerPage>100</NumberPerPage>
    </Value>
    </Values>;

    What is the right code to show in the combo the values of all the node "Label"?

    The following doesn't work
    combo.dataProvider = sample.Values.Value.Label;

    Thank you
    Regards

    garag Guest

  2. Similar Questions and Discussions

    1. How to populate a DataProvider with XML and AS only
      Hi there, after having spent 2 hours, I decided to get some help from you. Here's what I'd like to do. I have an XML file that I'd like to...
    2. Populate Combo box with value 'ALL'
      Have read in a query to a combo box but need to have an additional value of ALL in the combo box to enable our filter to work. How can i do this,...
    3. Populate Text Box
      I have a form with a drop box and some text boxes(Fname, Lname, M). A drop box is displayed all name from the database with this format: lname,...
    4. Best way to populate a <SELECT>
      Hi All I've being doing it my own little way for sometime now, but I'm not sure if its the best. When I'm doing a recordset for a simple...
    5. populate combo in asp
      Can someone please tell me what they think is wrong with this code to populate a combo : <select name="select"> <% While ((Repeat1__numRows <>...
  3. #2

    Default Re: Combo box populate from xml

    I think you will find this very useful:
    [url]http://thanksmister.com/xmlcombo/index.html[/url]

    I hope this solves your problem.

    Best regards.
    Xyrer Guest

  4. #3

    Default Re: Combo box populate from xml

    This should get you started. Check the docs for more samples.

    TS

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

    <mx:Script>
    <![CDATA[

    private function init() : void {
    var sample:XML =
    <Values>
    <Value>
    <Label>20 per page</Label>
    <NumberPerPage>20</NumberPerPage>
    </Value>
    <Value>
    <Label>50 per page</Label>
    <NumberPerPage>50</NumberPerPage>
    </Value>
    <Value>
    <Label>100 per page</Label>
    <NumberPerPage>100</NumberPerPage>
    </Value>
    </Values>;
    cb.dataProvider = sample.Value;
    cb.labelField = "Label";
    }

    private function showValue(event:Event):void
    {
    ta.text += "You've selected " +
    event.target.selectedItem.NumberPerPage.toString() + " items per page. \n";
    }

    ]]>
    </mx:Script>

    <mx:ComboBox id="cb" close="showValue(event)" prompt="Select number per
    page"/>
    <mx:TextArea id="ta" width="300" height="200" />

    </mx:Application>

    VarioPegged Guest

  5. #4

    Default Re: Combo box populate from xml

    Hi guys,

    thank you for your suggestions, they works.

    I forget to write in my first post that I had also tried with:

    combo.dataProvider = sample.Values.Value;
    combo.labelField = "Label";

    but it still didn't work because a XML variables already contains the root
    node of the xml.

    Many thanks


    Regards,


    garag Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139