使用动态数据Hillel Coren进行Flex自动完成多重选择

时间:2014-01-19 11:49:27

标签: flex autocomplete flex4 dynamic-data multi-select

我正在尝试使用Hillel Coren component在apache flex 4中添加多选自动完成功能。

它工作得很好,但除非我在#3中静态设置arrayCollection,否则我无法使用多个选项。我可以在框中输入以选择第二项,但是当我选择没有任何事情发生时。

有没有人有任何想法?这是代码。

MXML

<components:AdvancedAutoComplete id="autoComplete3" dataProvider="{ mainDataArrayCollection }" 
        labelField="name" matchType="word" 
        prompt="Choose your favorite Player 3" width="100%"
        selectedItemStyleName="facebook"
        allowMultipleSelection="true" showRemoveIcon="true" 
                                 />

的Actionscript

private function dataHandler(event: ResultEvent) : void {
mainData = event.result.playerStats;

mainDataCollection = new XMLListCollection(mainData);


    // #1
var resultArray:Array = mainDataCollection.toArray(); 
mainDataArrayCollection = new ArrayCollection(resultArray);

   // #2
mainDataArrayCollection = new ArrayCollection();
for each ( var xml:XML in mainData ) {
        var playerObj = new Object;
        playerObj.name = xml.player;
        playerObj.id = xml.id.toString();
            mainDataArrayCollection.addItem(playerObj);

}

    //  #3
   //  Only method that will allow multiple select.
mainDataArrayCollection = new ArrayCollection(
            [
                { "name":"Pujols Albert", "id":"1" },
                { "name":"Homer Orange", "id":"2" }
            ] );

0 个答案:

没有答案