Search code examples
apache-flexdatagridsortcomparefunction

flex datagrid - is it possible call a sortCompareFunction on initialize


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


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.