【问题标题】:ExtJS Paging Grid will not advanceExtJS Paging Grid 不会前进
【发布时间】:2014-11-04 17:49:09
【问题描述】:

我正在尝试在 ExtJS 5 中实现一个带有分页工具栏的网格。我得到了第一页数据,但是在推进网格时不会更新新数据。

似乎 data.asp 页面没有使用新的起始值更新以更新我的记录集的 .AbsolutePosition 属性。所以网格一直显示第一页信息。

我的代码在下面...

    var gridStore = Ext.create('Ext.data.JSonStore', {
         autoLoad: false,
         fields: [
             {name: 'field1', type: 'int'},
             {name: 'field2', type: 'int'}
         ],
         pageSize: 25,
         proxy: {
              type: 'ajax', 
              url: 'Data.asp',
              reader: {
                   type: 'json',
                   rootProperty: 'rows',
                   totalProperty: 'totalCount',
              }
         }
    });

    gridStore.load({
         params: {
               start: 0,
               limit: 25
         }
    });

    grid = Ext.create('Ext.grid.Panel', {
        renderTo: 'grid-Spec',
        store: gridStore,
        columns: [
            {text: 'Field 1', width: 10, sortable: true, dataIndex: 'field1'},
            {text: 'Field 2', width: 10, sortable: true, dataIndex: 'field2'}
        ],
        height: 100,
        width: 20,
        selModel: { mode: 'SINGLE' },
        dockedItems: [{
            xtype: 'pagingtoolbar',
            store: gridStore,
            dock: 'bottom',
            displayInfo: true
        }]
    });

【问题讨论】:

    标签: extjs extjs5


    【解决方案1】:

    您的代码有一些拼写错误,但总体上看起来还不错。

    问题可能出在服务器端 - 使用 ajax 代理时,您必须在服务器端实现分页。如果您在服务器端实现了分页,请使用一些开发人员工具(例如在 Chrome 中)并查看是否正确提交了页码。您应该在地址中看到开始/页码(例如:http://fiddle.jshell.net/echo/json/?_dc=1410854522824&page=2&start=5&limit=5)。

    我做了小提琴:http://jsfiddle.net/seur2aLx/9/ 你可以将你的代码与我的代码进行比较(注意Ext.ux.data.reader.Json 只是为了伪造一些网格数据)。

    【讨论】: