FLEX: I lose current datagrid selection if I sort differently the items of its dataProvider.
- by Patrick
hi,
when I sort differently my datagrid items, I lose the current selection.
This is the code. I'm using savedSelectedItems array to restore the selectedItems but it doesn't work. How can I save the current selection.
private function sortItems(option:String):void {
//save selectedItems
savedSelectedItems = tagsList.selectedItems;
if (option == "tag") sort.fields = [new SortField("tag",true)];
if (option == "popularity") sort.fields = [new SortField("popularity",true)];
fullTagsDataModel.tagsData.sort = sort;
fullTagsDataModel.tagsData.refresh();
tagsList.selectedItems = savedSelectedItems;
}
...
<!-- tags list -->
<dataGrid:CheckBoxList id="tagsList"
width="100%"
height="100%"
initialize="tagsList.dataProvider=fullTagsDataModel.tagsData"
labelField="tag"
itemRenderer="com.CheckBoxListAndDataGrid.CheckBoxRenderer"
allowMultipleSelection="true"
click="savedSelectedItems = tagsList.selectedItems"
/>