labelField asking

109 Views Asked by At

hi guys i have xml database how to call phone and display in label ? i already have label Field but i want to call phone in side the Field

how ?

this my cod

<s:List id="lst" x="73" y="197" width="295" height="214" change="lst_changeHandler(event)"
            dataProvider="{arr}" fontSize="30" fontWeight="bold" 
             textAlign="right">
        <s:labelField>RestaurantsKuwaiti</s:labelField>

http://www.mlfnt.com/lives6/13510357301.png

1

There are 1 best solutions below

0
On

First of all, your xml is not like a list:

   <RestaurantsKuwaiti>
   ...
   <RestaurantsOther>
   ...
I think it should be like:
   <Restaurants>
     <name>Kuwaiti</name>
   </Restaurants>
   <Restaurants>
     <name>Syria</name>
   </Restaurants>
   ...

use labelFunction can solve your problem:

  <fx:Script>
    <![CDATA[
      import mx.collections.XMLListCollection;

      private var xml:XML = 
        <dataroot>
          <alldata>
            <ID>1</ID>
            <Main>2</Main>
            <RestaurantsKuwaiti>
              <phone>55555555</phone>
            </RestaurantsKuwaiti>
          </alldata>
        </dataroot>;

      [Bindable]
      private var dataList:XMLListCollection = new XMLListCollection(xml.alldata);

      private function labelFunc(item:Object):String {
        return item.RestaurantsKuwaiti.phone;
      }
    ]]>
  </fx:Script>

  <s:List dataProvider="{dataList}" labelFunction="labelFunc"/>

as I mentioned above, the "dataList" has only one item: "alldata".