如何限制网格ExtJS中的商店结果数量?

时间:2015-05-19 10:26:49

标签: extjs

你能帮帮我们吗?我在使用loadRawData时遇到问题。我在网格视图中的分页工具栏计算所有记录和页面,但它无法切换页面。此外,网格查看我的商店中的所有记录,它高于1000。 在页面上单击,下一个或上一个单击显示的错误

"Uncaught TypeError: Cannot read property 'indexOf' of undefined"

我的商店在这里:

var objStore = Ext.create('Ext.data.Store',{
    //model: 'objModel',
    storeId: 'allObjects',
    autoLoad: false,
    pageSize: 30,
    sorters: [{
        property: 'nm',
        direction: 'asc'
        }],
    fields:[
        {name: 'nm', type: 'string'},
        {name: 'id', type: 'string'}
    ],
    proxy: {
        type: 'ajax'
    },
    loadRawData: function(data,append){
        var me = this,
        result = me.proxy.reader.read(data),
        records = result.records;

        if (result.success) {
            me.totalCount = objArr.totalItemsCount;
            me.currentPage = 1;
            me.loadRecords(records,{addRecords: append});
            me.fireEvent('load',me,records,true);
        }
    }
});

我的网格:

 var pagingTb = Ext.create('Ext.PagingToolbar', {
    store: objStore,
    displayInfo: true,
    displayMsg: 'Показано  {0} - {1} из {2}', // формат инфо
    loadPage: function(page) {
        var me = this;

        me.currentPage = page;

        me.read({
            page: page,
            start: (page - 1) * me.pageSize,
            limit: me.pageSize,
            addRecords: !me.clearOnPageLoad
        });
    }
});

var objGrid = Ext.create('Ext.grid.Panel', {
id: 'grid',
store: objStore,
height: 500,
columns: [
        {header:'№',xtype: 'rownumberer',width:40,style:'text-align:center;'},
        {text: 'ID', dataIndex: 'id', width: 50,style:'text-align:center;'},
        {text:'Объект', dataIndex: 'nm', width: 300,style:'text-align:center;'}
    ],
bbar: pagingTb
});

我在按钮的听众中的请求:

listeners:{
            click:{
                    fn: function() {
                        request=Ext.Ajax.request({
                        method: 'POST',
                        url: 'myurl',
                        success: function(response, opts){
                        objArr = Ext.decode(response.responseText);
                        var store = Ext.data.StoreManager.lookup('allObjects');
                        store.loadRawData(objArr.items, true);
                        },
                        failure: function(response, opts) {
                        console.log('server-side failure with status code ' + response.status);
                            }
                        });
                    }
            }
        }

0 个答案:

没有答案