2011-02-11 66 views

回答

1

假設我明白你正確地問什麼,並假設您的dataProviderArrayCollection

獲取所選行的索引你的數據提供程序:

var rowIndex:int = myArrayCollection.getItemIndex(myDataGrid.selectedItem); 

爲了獲取對象在DataGrid的dataProvider中:

var obj:Object = myDataGrid.selectedItem; 

由於DataGrid回收其itemRenderers以提高內存性能,因此dataProvider中沒有特定對象的特定行索引。當您滾動並且記錄不再可見時,那些記錄itemRenderers將重新用於滾動到視圖中的新記錄。您可以閱讀itemRenderers和回收here的更多信息。

編輯: 下面是一個例子的鏈接瞭解如何在DataGrid中篩選數據:

http://www.flex-blog.com/arraycollection-filter-example/

+0

是數據提供程序中的索引總是將是行索引關係嗎?我認爲會有一些內置的選項,如分頁或過濾,這會使網格隱藏一些行。也許這是從來沒有這樣(雖然我是新來的Flex,所以我不知道)。 – Ocelot20 2011-02-13 13:47:12

相關問題