Search code examples
apache-flexactionscript-3sortingadvanceddatagridarraycollection

Refresh GroupCollection of an AdvancedDatagrid - the sorted Arraycollection gets Randomized


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?


Solution

  • 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(); }