Reputation: 201
I have an ArrayCollection which is a dataProvider to the DataGrid. The ArrayCollection may look like that:
{Name: Bob; LikesIceCream:YES},
{Name: Carl; LikesIceCream:NO},
{Name: Ed; LikesIceCream:NO}
I want to have a checkbox, which would make the DataGrid show either all people when it is checked, or only those who have a property LikesIceCream:NO when it is not checked. How do I achieve that?
Upvotes: 1
Views: 369
Reputation: 153
You can use filterFunction property of ArrayCollection.
Write your own function that will filter collection:
function myFilterFunction(item: Object): Boolean { var result: Boolean = true; if (!checkBox.selected) { result = (item.LikesIceCream == "Yes"); } return result; }
Set collection filterFunction property
collection.filterFunction = myFilterFunction;
Refresh collection initially and after check box change
collection.refresh();
Upvotes: 2