简体   繁体   中英

Flex DataGrid autoscroll on dataProvider change

My Flex datagrid automatically scrolls to the top when I update the dataProvider (ArrayCollection). I do not want this to happen, but I still want all of the objects to update . I am developing a semi-real time dashboard for a customer's management system, that will update often. If it scrolls to the top every time it updates, it will be very difficult and frustrating to use.

I've attempted to use the following techniques to prevent this, none have worked.

dataProvider = updatedDataProvider;
dataProvider.updateItem(dataProvider);

dataProvider.source = updatedDataProvider.source;
dataProvider.updateItem(dataProvider);

I've attempted to dispatch a mouse event to hold the vertical scrollbar in place, I've attempted to lock the vertical scrollbar position value in place (saving and reassigning)...

And many others, those are just the first few that popped into my head. Anyone have any ideas?

Already been answered in How do I maintain selection in a DataGrid when the data changes? , check it.

Building on top of that answer, if the index changes between data providers, ie, if a row is inserted above, you may want to do a getItemIndex on the new provider.

如果您选择先前选择的任何内容并使用sureIndexIsVisible()怎么办?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM