views:

1177

answers:

2

I have a flex datagrid. it is bound to an array collection. if the user sorts on column X it works fine. then, if the user causes the array collection to change, the datagrid forgets that it was sorted on column X.

what do I need to do to preserve this sort preference so that the new array data will appear sorted by column X?

A: 

I have same kind of problem but didnt knw why it was happening so did some tweaking

selectedItems=dataGrid.selectedItems;

postionGrid=dataGrid.verticalScrollPosition;

sortPostionGrid=dataGrid.dataProvider.sort;

store them in a variable and when data is changed just put the again on the grid it is not a good approach but it worked for me

Rahul Garg
+2  A: 

I posted this question on another forum and got a good answer that worked well. Here it is:

If your data is in ArrayCollections you can assign a ListCollectionView to the dataProvider property of your child AdvancedDataGrid and assign your ArrayCollection data to the 'list' property of the ListCollectionView. When you want to change the data in the child grid, reassign the list property of the ListCollectionView. This way you avoid reassigning the dataProvider of the child grid directly, which is what causes the grid to reset.

here's the link to the post: http://forums.adobe.com/message/2206736#2206736

This works pretty well.
Rob Lund