views:

424

answers:

3

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

A: 

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.

Amarghosh
A: 

this thread is quite old but i'm having the same pb and it doesn't work, the event is dispatched as it's captured if i do

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

private function headerReleaseHandler(event:DataGridEvent):void {
    var dg:DataGrid = event.currentTarget as DataGrid; 
    trace("event: " + event);
}

i have this result:

event: [DataGridEvent type="headerRelease" bubbles=false cancelable=true columnIndex=0 rowIndex=-1 itemRenderer=[object HeaderRenderer] dataField="jour" reason=null]

but the grid doesn't change at all

any ideas??

Zied