Reputation:
I have
DataGrid contains 4 columns:
No. OrderTitle OrderDescription Price
Now, DataGrid has 100 record. And I want to filter DataGrid using first arraycollection(ordersAC) which is dynamically changed every time.
like: ordersAC has 5 orderId
1521, 2154, 2233, 5484, 2351
then in DataGrid display only 5 records depend on orderId
.
I tried following ways but didn't work:
private function onSearchRecordClick(event:FlexEvent):void
{
var orderAC:ArrayCollection = ordersGridId.orderAC;
for(var i:int = 0; i<ordersRecordAC.length-1;i++)
{
orderAC.filterFunction = filterRows;
function filterRows(item1:Object):Boolean
{
if(item1.orderId == ordersRecordAC[i])
return true;
else
return false;
}
}
orderAC.refresh();
}
<mx:DataGrid id="ordersGridId" lockedColumnCount="5" dataProvider="{orderAC}" sortableColumns="true">
Hope Understand my question.
Thanks.
Upvotes: 1
Views: 354
Reputation: 71
I would do the following w/ your code.
private var orderAC:ArrayCollection; // assign this somewhere else
private function onSearchRecordClick(event:FlexEvent):void
{
if(!orderAC.filterFunction)
orderAC.filterFunction = filterRows;
orderAC.refresh();
}
private function filterRows(item1:Object):Boolean
{
for(var i:int = 0;i < ordersRecordAC.length;i++)
{
if(item1.orderId == ordersRecordAC[i])
return true;
}
return false;
}
Upvotes: 1