ExtJs Paging忽略totalProperty

时间:2013-04-17 14:02:47

标签: extjs extjs4.1

我使用ExtJs 4.1

我的网格工作正常,但我在设置正确的分页时遇到问题。分页工具栏会记录错误的记录和页数。

服务器总共有8行,但只返回指定的4行。所以它应该是2页,每页4行。

初始加载的

Json 如下所示:

{
    "value": {
        "data": [{
                "id": "user1",
                "title": "index0"
            }, {
                "id": "user2",
                "title": "index1"
            }, {
                "id": "user3",
                "title": "index2"
            }, {
                "id": "user4",
                "title": "index3"
            }
        ],
        "total": 8,
        "page": 1,
        "pages": 2,
        "pagesize": "4"
    }
}

设置

nItemsPerPage = 4;

Pagingtoolbar

var oPagingToolbar = Ext.create( 'Ext.toolbar.Paging', {
            store         : oStoreUsers,
            pageSize      : nItemsPerPage,
            dock          : 'bottom',
            displayInfo   : true
         } );

我的网格包含商店oStoreUsers,并且页面工具栏已停靠。

已加载

商店

// tried each of the following lines for loading
// none gave me 2 pages
oStoreUsers.load( { params: { start: 0, limit: nItemsPerPage } } );
oStoreUsers.loadPage( 1 );
oStoreUsers.loadPage( 1, { params: { start: 0, limit: nItemsPerPage } } );

商店的属性如下:

root: 'value.data',
pageSize: nItemsPerPage

问题:将4行加载到商店中并显示在网格中。 但是,分页工具栏显示Page 1 of 1Displaying 1 - 4 of 4,应该Page 1 of 2Displaying 1 - 4 of 8

如何让它发挥作用?


编辑:

reader

   reader: {
           type         : 'json',
           root         : 'value.data',
           totalProperty: 'total'
        }

1 个答案:

答案 0 :(得分:3)

您的totalProperty不正确。需要value.total