Using a standard Flex DataGrid, is there an easy way to determine the grid row index given the data object or index of the data object in the data provider? On the flip side, is there a way to get the index of an object in the data provider based on the DataGrid row index? Thanks in advance!
Actionscript – Flex DataGrid: Get Data Object from row index & vice versa
actionscriptapache-flexdatagriddataprovider
Best Answer
Assuming I understand what you're asking for correctly and assuming your
dataProvider
is anArrayCollection
:To get the selected row's index in your dataProvider:
To get the object in your dataProvider from the DataGrid:
Since DataGrid's recycle their
itemRenderers
to improve memory performance, there's no specific row index for a given object in yourdataProvider
. As you scroll and records are no longer visible, those recordsitemRenderers
are reused for new records that scroll into view. You can read up more onitemRenderers
and recycling here.EDIT: Here's a link to an example on how to filter your data in a dataGrid:
http://www.flex-blog.com/arraycollection-filter-example/