DataGrid 的 Dojo 滚动问题

发布于 2024-10-31 12:48:40 字数 294 浏览 0 评论 0原文

我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

会傲 2024-11-07 12:48:40

当然,您每秒都会完全清除存储并从头开始重置它。当你重置商店时,你基本上重置了网格。我希望当您刷新其存储时网格会重置滚动位置。

您可能想了解如何正确使用商店,而不仅仅是尝试重置它。我在这里回答了这个问题:

如何刷新数据网格

如果你正确使用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.

野の 2024-11-07 12:48:40

经过(dojo)datagrid.js后,我找到了如何解决该问题:

//datastore you're using//
var store = new dojox.data.QueryReadStore({ 
   //in the fetch()//
   fetch: function (request){
        //add the following://
        request.isRender = false; 
   }
});

重要:当您不希望网格出现时,仅将 request.isRender 设置为 false滚动回到顶部。请记住,在某些情况下(例如在新列上排序),最好将其设置为 true。只需添加一些 if/else 语句来帮助逻辑。

After going through (dojo) datagrid.js, I found how to resolve the issue:

//datastore you're using//
var store = new dojox.data.QueryReadStore({ 
   //in the fetch()//
   fetch: function (request){
        //add the following://
        request.isRender = false; 
   }
});

Important: Only set request.isRender to false 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 to true. Just add some if/else statements to help with the logic.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文