2012-02-27 31 views
0

我有一個for循環,並在循環內調用遠程對象方法,該方法返回ArrayCollection。在循環的每次迭代中,ArrayCollection的內容發生變化,並且我在每次迭代中將的dataProvider設置爲ArrayCollectionArrayCollection在循環內未刷新

但是,只有我最後的ComboBox被綁定到ArrayCollection的最新內容。

remote_obj.getYN是將循環中的值作爲參數使用的函數,正如我在上面每次提到的那樣,由於調用了此函數,arrayCollection的內容會發生變化。

下面是我的代碼片段:

public function myFunc():void{ 

    for (roller = 0; roller < customizedFields_array.length; roller++) { 
     var newCol:FlexDataGridColumn = new FlexDataGridColumn(); 
     remote_obj.getYN(customizedFields_array.getItemAt(roller).FLD); 
     newCol.filterComboBoxDataProvider = _YN; 
     newCol.filterComboBoxLabelField =customizedFields_array.getItemAt(roller).FLD; 
     newCol.filterComboBoxDataField =customizedFields_array.getItemAt(roller).FLD; 
     } 
     cols.push(newCol); 
    } 
     myDataGrid.columns = cols; 
} 

這是在Flex getYN結果函數。

public function getYN_result(event:ResultEvent):void{ 
    _YN = event.result as ArrayCollection; 
} 

有人能告訴我如何解決這個問題? 非常感謝您的寶貴幫助。

回答

0

試試這個:

customizedFields_array.refresh(); // refresh the array collection 
myDataGrid.invalidateDisplayList();// refresh the datagrid 
+0

的customizedFields_array只是returing在我環路lsit。需要在每次迭代中更新的關注數組是_YN arrayCollection。所以你的意思是設置newCol.filterComboBoxDataProvider = _YN後,我需要刷新()數組? – yaya 2012-02-27 15:28:38

+0

嘗試刷新它...當我有autorefresh問題array.refresh()總是工作... – Marcx 2012-02-27 16:33:08

+0

我試過了..但是白白的..它不工作。請提供其他幫助嗎? – yaya 2012-02-28 07:12:30