Programmaticaly sorting a column in an AdvancedDataGrid

ActionScript, Flex, tips 'n tricks Add comments

Here's a quick tip: If you want to sort a column of an AdvancedDataGrid, without having to set up a sort on the dataprovider, you can dispatch an AdvancedDataGridEvent of type AdvancedDataGridEvent.SORT from the datagrid.

This can be useful if you have a custom sort function on a datagrid column and you want the datagrid to be sorted initially without requiring the user to click the column header.

Actionscript:
  1. var sortEvent:AdvancedDataGridEvent = new AdvancedDataGridEvent(AdvancedDataGridEvent.SORT);
  2. sortEvent.columnIndex = 0; // first column
  3. dataGrid.dispatchEvent(sortEvent);


Add to Bloglines - Digg This! - del.icio.us - Stumble It! - Twit This! - Technorati links - Share on Facebook - Feedburner
 

Leave a Reply

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in