开发者

AdvancedDataGrid initial column sort

开发者 https://www.devze.com 2023-01-25 12:22 出处:网络
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

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}">
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号