2012-06-05 56 views
0

爲什麼無法填充我的下拉列表。 我在http://www.adobe.com/devnet/flex/videotraining.html做視頻。 值不在nameSaleChoose.how中。 請幫幫我。無法使用xmldocument填充我的下拉列表

我想在下拉菜單中顯示LocalDesc。

<?xml version="1.0" encoding="utf-8"?> 
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
xmlns:s="library://ns.adobe.com/flex/spark" 
xmlns:mx="library://ns.adobe.com/flex/mx" 
width="320" height="480" 
    creationComplete="initApp()"> 
<fx:Script> 
    <![CDATA[ 
     import mx.collections.ArrayCollection; 
     import mx.controls.Alert; 
     import mx.rpc.events.FaultEvent; 
     import mx.rpc.events.ResultEvent; 
     import spark.events.IndexChangeEvent; 
     [Bindable] 
     private var nameSaleChoose:ArrayCollection; 
     protected function service_resultHandler(event:ResultEvent):void 
     { 
      // TODO Auto-generated method stub 
      nameSaleChoose = event.result as ArrayCollection; 
     } 
     private function initApp():void 
     { 
      service.GetXml("SELECT PositionCode,LocalDesc 
        FROM StaffPosition WHERE PositionCode IN ('00000','00021')"); 
     } 
    ]]> 
</fx:Script> 
<fx:Declarations> 
    <s:WebService id="service" 
        wsdl="http://192.168.1.25/service.asmx?wsdl" 
        result="service_resultHandler(event)" 
        > 
    </s:WebService> 
</fx:Declarations> 
<s:DropDownList id="dropDownList" x="35" y="38" width="164" 
    dataProvider="{nameSaleChoose}" labelField="LocalDesc"> 
</s:DropDownList> 

此xml:從Web服務回報

<?xml version="1.0" encoding="UTF-8"?> 
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http:// 
    www.w3.org/2001/XMLSchema-instance"> 
<soap:Body> 
<GetXmlResponse xmlns="http://tempuri.org/"> 
    <GetXmlResult> 
    <NewDataSet xmlns=""> 
     <Table> 
     <PositionCode>00000</PositionCode> 
     <LocalDesc>Administrator</LocalDesc> 
     </Table> 
     <Table> 
     <PositionCode>00021</PositionCode> 
     <LocalDesc>saleman</LocalDesc> 
     </Table> 
    </NewDataSet> 
    </GetXmlResult> 
    </GetXmlResponse> 
</soap:Body> 
</soap:Envelope> 

回答

0

之所以這樣,是你的結果是XML格式,並嘗試將其丟在ArrayCollection中。 您應該使用XMLListCollection類。

+0

請exsample給我。 – barmboy