extjs在商店后保持网格滚动位置



我在grid.Panel中有一个动作列,该列更改字段值并保存存储数据。但是,每次调用store.save时,网格滚动位置都返回到top:0

示例代码:

Ext.define('SF.view.Myview.List' , {
    extend: 'Ext.grid.Panel',
    viewConfig: {
        preserveScrollOnRefresh: true,
    },
    store: 'Contents',
    initComponent: function() {

        this.columns = [
            { xtype: 'actioncolumn',
            header: 'Action'
            , width: 60
            , items: [{ // change status button
                icon: 'http://whatisextjs.com/BAHO/icons/cancel.png'
                , handler: function(grid, rowIndex, colindex) {
                    var record = grid.getStore().getAt(rowIndex);
                    record.set('status',6);
                    grid.store.save();
                } 
            },

我已经尝试了preserveScrollOnRefresh属性而没有成功。此属性适用于分页和工具栏按钮,但在store.refresh/load事件中不行。

是否可以保存数据并刷新行而不会丢失滚动位置?

是的,呼叫记录的保存方法:

var record = grid.getStore().getAt(rowIndex);
record.set('status',6);
record.save();

和网格中的数据也将更新。

最新更新