views:

510

answers:

2

I have an AdvancedDatagrid which gets populated by an ArrayCollection.

I ordered the ArrayCollection by date (one of its properties), so it shows from past to future. The thing is, if I refresh the GroupingCollection (for immediate display in the datagrid) After the Sorting of the ArrayCollection, the ordering of the dates in the ArrayCollection gets scrambled again, but displays the populated AdvancedDatagrid immediately.

So in sum: from ArrayCollection > Sorting > Refresh the GroupingCollection > Populates the Adv.DataGrid, but the ArrayCollection is not sorted anymore.

Anybody stumbled on such an obstacle before?

A: 

Sort the DataGrid instead of the dataProvider - change the view, not the model. Set the sortableColumns property of the grid and sortable property of the column to true. Use the sortCompareFunction property of the column if necessary.

Amarghosh
sotableColumns for the Adv.DataGrid sets the click option of sorting that column to enabled, does not sort it.sortable property to the column to true, just gives me the enabling capacity to be sortable.sortableColumns = false, overrides and disables the column even if sortable is true.My dates are not sortable. Note though, even if I sort the column (click on header) it works beautifully. Just not be default.
Yozef
A: 

Solved:

private function populateGrid():void {

gc.source = siteTrafficData; gc.refresh();

adv_dg.validateNow();

var sort:Sort = new Sort(); sort.fields = [new SortField("date")]; IHierarchicalCollectionView(adv_dg.dataProvider).sort = sort; IHierarchicalCollectionView(adv_dg.dataProvider).refresh(); }

Yozef