AdvancedDataGrid initial column sort
I have an AdvancedDataGrid with mx:HierarchicalData as DataProvider. I need the grid to bi sorted on the second column initially but can't find any way to specify this. Even if I sort the collection befor setting it into the mx:HierarchicalData only the first level remains sorted, while all the child records ge开发者_JAVA技巧t randomized. How to solve this?
Use a HierarchicalCollectionView
as dataprovider and sort it.
[Bindable]
private var hierarchicalView:IHierarchicalCollectionView;
private function createHierarchicalView():void
{
hierarchicalView = new HierarchicalCollectionView(hierarchicalData);
hierarchicalView.sort = new Sort();
hierarchicalView.sort.fields = [new SortField('field2') /* add additional fields if needed */];
hierarchicalView.refresh();
}
<mx:AdvancedDataGrid designViewDataType="tree" dataProvider="{hierarchicalView}">
精彩评论