Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Extjs Grid-将变量回调存储到pagingtoolbar中_Extjs_Grid_Extjs4_Extjs4.1 - Fatal编程技术网

Extjs Grid-将变量回调存储到pagingtoolbar中

Extjs Grid-将变量回调存储到pagingtoolbar中,extjs,grid,extjs4,extjs4.1,Extjs,Grid,Extjs4,Extjs4.1,I init将变量存储在gridpanel的'initComponent'中,如 initComponent: function() { var store = Ext.create('Ext.data.Store', { model: 'MyDataObject', pageSize:_end, proxy: { type: 'ajax',

I init将变量存储在gridpanel的'initComponent'中,如

    initComponent: function() {
        var store = Ext.create('Ext.data.Store', {
            model: 'MyDataObject',
            pageSize:_end,
            proxy: {
                 type: 'ajax',
                 url: myurl,
                 reader: {
                    type: 'json',
                    totalProperty: 'total', // total data, see json output
                    root: 'results'    // see json output                   
                 }
             }
        });
        this.store = store;
        this.callParent(arguments);
        this.store.load({params:{start:_star, limit:_end}
    });
我打电话给pagingtoolbar中的商店

dockedItems: [
        {
            xtype: 'pagingtoolbar',
            dock: 'bottom',
            store: this.store,
            pageSize: _end,
            displayInfo: true,
            displayMsg: 'Displaying results {0} - {1} of {2}',
            emptyMsg: 'No results'
        }
]
在我的gridpanel中仍然有数据,但底部显示“无结果”,如


我认为问题是商店:这个。商店,。我怎样才能让它工作呢?谢谢。

我在这里找到了解决方案 代码必须如下所示:

        this.store = store;
        this.dockedItems = [{
           xtype: 'pagingtoolbar',
           store: this.store,
           displayMsg: 'Displaying results {0} - {1} of {2}',
           emptyMsg: 'No results',
           dock: 'bottom',
           displayInfo: true,
           pageSize: 22
        }];

        this.callParent(arguments);
        this.store.load({params:{start:0, limit:22}});

你可以这样定义一个商店

Ext.define('MyApp.store.MyDataStore', {
        extend: 'Ext.data.Store',
        model: 'MyDataObject',
        storeId: 'myStoreId',
        pageSize:_end,
        proxy: {
             type: 'ajax',
             url: myurl,
             reader: {
                type: 'json',
                totalProperty: 'total', // total data, see json output
                root: 'results'    // see json output                   
             }
         }
    });
然后将myStoreId分配给网格面板和pagingtoolbar的存储配置,框架(StoreManager)应该创建一个分配给这两个的存储


然后,您可以在存储上设置autoload=true,或者在网格的initComponent中创建一个新存储,然后在那里手动加载

我昨天遇到了一个奇怪的问题,在我修复这个问题之前,我猜网格和pagingbar中的存储状态都不是同步的,我花了很长时间用Firebug调试这个问题,换句话说,这些存储不是同一个存储,它们只是存储的同一个实例,所以可以用两种方法修复这个问题,第一个是创建一个全局变量store,两者可以共享它;第二个是使用bindStore方法

this.on('afterrender',function(){//this  is grid itself
        this.getBottomToolbar().bindStore(this.store)//set store of paggingtoolbar
    },this);