DataGrid 的 Dojo 滚动问题
我在 DOJO 中使用 DataGrid 时遇到问题。我用这段代码每 1 秒刷新一次网格
window.store_data_log= new dojo.data.ItemFileReadStore({data:{items:temp}});
var grid = dijit.byId("grid_log");
grid.setStore(window.store_data_log);
,它工作正常(放入新数据)。问题是,当我有很多行并且向下滚动时,我的网格会刷新并且滚动到顶部网格。如何解决这个问题?
I have problem in DOJO with DataGrid. I refresh my grid on every 1 sec with this code
window.store_data_log= new dojo.data.ItemFileReadStore({data:{items:temp}});
var grid = dijit.byId("grid_log");
grid.setStore(window.store_data_log);
and it works fine ( put new data ). Problem is that when I have lot off rows and I scroll down, my grid refreshs and my scroll goes on top grid. How to solve this ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当然,您每秒都会完全清除存储并从头开始重置它。当你重置商店时,你基本上重置了网格。我希望当您刷新其存储时网格会重置滚动位置。
您可能想了解如何正确使用商店,而不仅仅是尝试重置它。我在这里回答了这个问题:
如何刷新数据网格
如果你正确使用dojo,你会得到很好的结果,但是如果只是走捷径并尝试每秒刷新商店,您将得到一个无法使用的网格。
您需要退后一步并解决您的应用程序架构,并且不要指望网格刷新是某种神奇的解决方案。
Of course, you are totally clearing the store and resetting it every second from scratch. When you reset the store, you basically reset the grid. I would expect nothing less than the grid resetting the scroll position when you refresh its store.
You may want to learn how to properly use the store rather than just trying to reset it. I answered this here:
How to refresh datagrid
If you use dojo properly, you will get good results, but by just taking a shortcut and trying to refresh the store every second you are going to get an unusable grid.
You need to take a step back and solve your application architecture and not expect the grid refresh to be some kind of magic solution.
经过(dojo)datagrid.js后,我找到了如何解决该问题:
重要:当您不希望网格出现时,仅将
request.isRender
设置为false
滚动回到顶部。请记住,在某些情况下(例如在新列上排序),最好将其设置为true
。只需添加一些 if/else 语句来帮助逻辑。After going through (dojo) datagrid.js, I found how to resolve the issue:
Important: Only set
request.isRender
tofalse
when you don't want the grid to scroll back to the top. Just keep in mind that some situations (like sorting on a new column), it's probably best to set it totrue
. Just add some if/else statements to help with the logic.