Search code examples
apache-flexsortingadvanceddatagrid

Sort Grouped Columns in AdvancedDatagrid


I#m looking for a solution to sort all grouped colums in advancedDatagrid. It should be the same behavior like clicking in a columns head.

Please note, i'm not looking for a solution to sort the fields IN a the grouping. There is working solution named compareFunction.

But I'm not able to sort the two rows in my picture by column "Einnahmen". Sorry for the german word. Do you have an Idea? enter image description here

Thank you Frank


Solution

  • If you're looking to start the application with sorted columns, you need to simulate a header click upon creation/dateprovider update.

    Try this:

    <mx:AdvancedDataGrid id="adg"
      updateComplete="adg.dispatchEvent(new AdvancedDataGridEvent(AdvancedDataGridEvent.HEADER_RELEASE, false, true, 3, 'Einnahmen'))">
        <mx:columns>
            ...
            <mx:AdvancedDataGridColumn dataField="Einnahmen" sortDescending="true" />
        </mx:columns>
    </mx:AdvancedDataGrid> 
    

    I haven't tried this for grouped collections but let me know how this works.