2012-10-11 45 views
1

我正在開發一個簡單的Web應用程序,它具有來自某些員工的簡單數據,例如ID,NAME等。因此,我使用XML文件作爲我的數據庫。然而,我的XML文件按僱員ID排序。如何對DropDownList組件中的數據進行排序?

不過,我使用的是選擇僱員的姓名和顯示有關他/她的一些信息,但是當我通過我的Spark組件(我只是「拖 - 放」創建的可綁定數據我的XML文件到組件中),我想顯示按名稱排序的這些名稱,這是我的問題。

這是一個簡單的代碼,但我遇到了麻煩......大聲笑!

<s:DropDownList id="ddNome" 
       labelField="NomeFuncionario" <!-- Employees' Name --> 
       textAlign="justify" 
       width="240" height="25" 
       top="30" horizontalCenter="0" 
       initialize="sortName(event)" <!-- Trying to create it now... --> 
       creationComplete="cbNome_creationCompleteHandler(event)" 
       change="cbNome_changeHandler(event)"> 

    <s:AsyncListView list="{getDataResult2.lastResult}"/> 

</s:DropDownList> 

我真的很感激這個代碼的幫助。

回答

0

,你可以嘗試這樣的事情

<mx:XMLListCollection id="xmlListColl" 
      source="{getDataResult2.lastResult}"> 
     <mx:sort> 
      <mx:Sort> 
       <mx:fields> 
        <mx:SortField id="sortField" 
          name="@NomeFuncionario" 
          caseInsensitive="true" /> 
       </mx:fields> 
      </mx:Sort> 
     </mx:sort> 
    </mx:XMLListCollection> 

    ... 
    <s:AsyncListView list="{xmlListColl}"/> 
    ... 
+0

我有錯與在標記塊。 Flash Builder告訴我「默認屬性'dataProvider'的類型爲'mx.collections.IList'的多個初始值設定項值。 – user1737997