Question

HI,

I want to call the sortCompareFunction for a particular row when the grids first loads. Is this possible? Otherwise is there a way to call a sort method on grid load after it has been asssigned the dataprovdier has been updatad

Was it helpful?

Solution

Dispatch a headerRelease event - I haven't tried this, but the DataGrid sorts upon receiving this event.

datagrid.dispatchEvent(new DataGridEvent(DataGridEvent.HEADER_RELEASE, 
        false, false, zeroBasedIndex_of_theColumn_ToSort, 
        dataField_of_that_column));

If this doesn't work, grab and pass the corresponding headerRenderer instance as the eighth parameter to the DataGridEvent constructor.

OTHER TIPS

Zied, in my case i need to call the sort function twice. First, when the grid first loads and second when the dataprovider is updated.

First time i call it is on a FlexEvent.CREATION_COMPLETE. At this point i have to do some exception handling to ensure that if the dataprovider is empty that i dont try and sort it.

myArrayCollection.sort = new Sort();
myArrayCollection.sort.fields = [new SortField("roomName", true, false, false)];
myArrayCollection.refresh();

The second time i call the sort function is on a CollectionEvent.COLLECTION_CHANGE event. This kicks off any time the dataprovider updates.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top