ExtJs 7.3 MODERN中的有状态网格

krugob8w  于 2022-11-23  发布在  其他
关注(0)|答案(1)|浏览(179)

我不明白,根据ExtJs 7.3 Modern的手册,应该可以配置一个Ext.grid.Grid(https://docs.sencha.com/extjs/7.3.0/modern/Ext.grid.Grid.html#cfg-stateful)。
我补充道:

({
  //  ...
  stateId: 'state-grid', 
  stateful: true, 
  // ... 
});

并且在列上还为每个列添加了一个stateId,在我添加的应用程序启动函数中:

launch: function() {
        Ext.state.Provider.register(new Ext.state.LocalStorage());
        Ext.get(Ext.query('#appLoadingIndicator')).remove();
        this.callParent(arguments);
}

但是我没有让有状态网格工作,也就是说,我隐藏了一个列,然后刷新了站点......这个列仍然是可见的。ExtJs 7.3 MODERN〈--- Modern not classic中的有状态工作也是如此。

nuypyhwy

nuypyhwy1#

看一下下面这个简单易懂的fiddle示例。它保存了网格列的宽度和隐藏属性:

Ext.application({
    name: 'Fiddle',

    launch: function () {
        Ext.state.Provider.register(new Ext.state.LocalStorage());

        var store = Ext.create('Ext.data.Store', {
            fields: ['name', 'email', 'phone'],
            data: [{
                'name': 'Lisa',
                "email": "lisa@simpsons.com",
                "phone": "555-111-1224"
            }, {
                'name': 'Bart',
                "email": "bart@simpsons.com",
                "phone": "555-222-1234"
            }, {
                'name': 'Homer',
                "email": "home@simpsons.com",
                "phone": "555-222-1244"
            }, {
                'name': 'Marge',
                "email": "marge@simpsons.com",
                "phone": "555-222-1254"
            }]
        });

        var grid = Ext.create('Ext.grid.Grid', {
            title: 'Simpsons',
            columns: [{
                text: 'Name',
                dataIndex: 'name',
                stateId: 'name-column-state-id',
                stateful: {
                    // we will state hidden and width of the column states only
                    hidden: true,
                    width: true
                }
            }, {
                text: 'Email',
                dataIndex: 'email',
                stateId: 'email-column-state-id',
                stateful: {
                    // we will state hidden and width of the column states only
                    hidden: true,
                    width: true
                }
            }, {
                text: 'Phone',
                dataIndex: 'phone',
                stateId: 'phone-column-state-id',
                stateful: {
                    // we will state hidden and width of the column states only
                    hidden: true,
                    width: true
                }
            }],
            store: store,
            layout: 'fit',
            fullscreen: true
        });

    }
});

相关问题