[英]keep my sort after updating the dataprovider's data
I have a datagrid where the data in the dataprovider changes every 30 seconds automatically.我有一个数据网格,其中 dataprovider 中的数据每 30 秒自动更改一次。 Everytime it does, if I chose to sort the column by clicking on the header, it will revert back to the default sort (before I clicked on the header).每次这样做时,如果我选择通过单击标题对列进行排序,它将恢复为默认排序(在我单击标题之前)。 I want to know how I can control the sorting so that if I had clicked on it previously, it will remain sorted as so the next 30 seconds.我想知道如何控制排序,以便如果我之前点击过它,它会在接下来的 30 秒内保持排序。
<mx:DataGrid id="id" width="100%" height="100%">
<mx:columns>
<mx:DataGridColumn dataField="@col1" headerText="Type1" itemRenderer="itemRenderer" />
<mx:DataGridColumn dataField="@col2" headerText="Type2" itemRenderer="itemRenderer" />
</mx:columns>
<mx:dataProvider>
{xmllist_extractedfromAnotherSourceEvery30Seconds}
</mx:dataProvider>
</mx:DataGrid>
A guess... The sort order is stored within the dataProvider (ArrayCollection), and it gets lost when you re-assign a new dataProvider.猜测...排序顺序存储在 dataProvider (ArrayCollection) 中,当您重新分配新的 dataProvider 时它会丢失。
You could either:你可以:
update the dataProvider using ArrayCollection update functions, instead of re-assigning it使用 ArrayCollection 更新函数更新 dataProvider,而不是重新分配它
if not possible, get the ISort from the dataProvider before changing it;如果不可能,请在更改之前从 dataProvider 获取 ISort ; then apply this ISort to the new dataProvider after loading (and remember to refresh() the dataProvider)然后在加载后将此 ISort 应用到新的 dataProvider(并记住刷新()dataProvider)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.