开发者

flex datagrid - is it possible call a sortCompareFunction on initialize

HI,

I want to call the sortCompareFunction for a particular row when the g开发者_JAVA技巧rids 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


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜