views:

32

answers:

2

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

A: 

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

alxx
Looks like @2DH has an easy way!
Amarghosh
+5  A: 

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);
2DH
+1. The filtering API is built into the ListCollectionView class. Any class extending that will offer the same filtering functionality. XMLListcollection is another option in the Flex Framework. I know there are other implementations out there in the community, such as the DataCollection from Farata Systems folk.
www.Flextras.com
i used this to hide row at 0 index but when i get the item from dataprovidor at index 0.. item is removed from dataprovidor .. i want value should be in dataprovidor but just dont appear.
Muhammad Husnain Ashfaq
is it possible to use dataDescriptor... ?
Muhammad Husnain Ashfaq