how to hide a row without deleting item from dataprovidor in DataGrid...AS3,Flex?

How we can hide a row at specific index of DataGrid in AS3 ?

Upvotes: 1

Views: 2992

Answers (2)

2DH
2DH

Reputation: 1638

If dataProvider of your DataGrid is ArrayCollection you can specify filterFunction property for it, something like that

dataProvider.filterFunction =
    function (item:Object):Boolean{
        if (dataProvider.getItemIndex(item)==indexOfRowYouWantToHide){
            return false;
        }
        return true;
    };

The item will still be in ArrayCollection but will be made invisible by the filter. Not the most efficient solution but it works. You need to call

dataProvider.refresh();

to apply the filter.

UPDATE: To access raw, unfiltered data of ArrayCollection you should use list property, so if you hid item at index 0 and still want to be able to access it you do that like this:

dataProvider.list.getItemAt(0);

Upvotes: 7

alxx
alxx

Reputation: 9897

No (easy) way. You can try to subclass DataGrid to add this functionality, but this will be really heavy task.

Upvotes: 0

Related Questions