ExtJs grid.Panel存储:加载/重新加载后保持滚动条位置 [英] ExtJs grid.Panel store: keep scrollbar position after load/reload

查看:264
本文介绍了ExtJs grid.Panel存储:加载/重新加载后保持滚动条位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Sencha ExtJs 4.0.2a中使用 grid.Panel ,并且每60秒重新加载一次Json Store.

I'm using grid.Panel in Sencha ExtJs 4.0.2a and I reload a Json Store every 60 seconds.

我想知道是否有一种方法可以在加载数据后保留滚动条的位置.
以便用户可以继续查看加载之前正在查看的记录.

I was wondering if there is a way to preserve the position of the scrollbar after a data load.
So that the user can continue to look at the records he was looking before the load..

我使用Task重新加载网格中的数据:

I reload the data in the grid using a Task:

var task = {
    run: function(){
        Ext.getCmp(panelGridId).getStore().load({
            //Callback function after loaded records
            callback: function(records) {
                //Hide grid if empty records
                if (Ext.isEmpty(records)) {
                    Ext.getCmp(panelGridId).setVisible(false);
                }
                else {
                    if (Ext.getCmp(panelGridId).isHidden()) {
                        Ext.getCmp(panelGridId).setVisible(true);
                        Ext.getCmp(panelGridId).doComponentLayout();
                    }
                }
            }
        });
    },
    interval: 60000 //60 seconds
};

Ext.TaskManager.start(task);

在加载数据后,滚动条位置将重置为顶部.

问:加载数据后是否可以保持滚动条的位置?

After the data load the scrollbar position is reset to the top..

Q: Is there a way to maintain the scrollbar position after the data load?

提前谢谢!

推荐答案

尝试这个坏男孩在刷新时保留滚动位置:

Try this bad boy to preserve scroll position on refresh:

http: //docs-devel.sencha.com/extjs/4.2.1/#!/api/Ext.grid.View-cfg-preserveScrollOnRefresh

这在我的树状视图上对我有用.

This works for me on my tree view.

viewConfig: {
   preserveScrollOnRefresh: true
}

这篇关于ExtJs grid.Panel存储:加载/重新加载后保持滚动条位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆