1

我有一个 JsonStore:

var store = new Ext.data.JsonStore({
        root: 'Data.items',
        remoteSort: false,
        fields: ['ClockTime', 'EmpId'],
        proxy: new Ext.data.HttpProxy({
            url: AppRootPath + 'Something/GetSomething',
            method: 'POST'
        })//proxy
});//new Ext.data.JsonStore

然后,我使用以下内容在此商店上调用 Load:

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

我有一个网格来显示这些数据:

    var grid = new Ext.grid.GridPanel({
    store: store,
    title:'Employees',
    stateful: true,
    id: 'grid',
    stripeRows: true,
    stateId: 'excp_list',
    bbar: new Ext.PagingToolbar({
        store: store,       
        displayInfo: true,
        prependButtons: true,
        emptyMsg: "No records to display",
        pageSize: 25
    }),
    viewConfig: {
        forceFit: true
    },
    columns: [
        {header: "Emp Id", width: 40, dataIndex: 'EmpId', sortable: true},
        {header: "Clock Time", width: 40, dataIndex: 'ClockTime', sortable: true}
    ]
 });

我预计这只会显示每页 25 条记录/行。但是它只显示一页,该页共有 160 条记录。我在这里遗漏了一些明显的东西吗?

4

3 回答 3

4

您缺少 Store/JsonReader 的 totalProperty。这应该是记录总数,分页工具栏需要知道这一点来计算页数等。此外,您的服务器需要发回正确的页面和总结果计数。看起来您的服务器正在发回所有记录并且忽略了 start 和 limit 参数。

于 2011-02-09T16:12:44.267 回答
3

肖恩87,

简而言之,您可能在这里遗漏的“显而易见”的事情是服务器有责任检测/读取开始和限制并仅发回“限制”记录数

否则,您的客户端代码看起来没问题,除了您可能想要检查的totalProperty ,如下面的 Robby 的回答所述。

于 2011-02-09T16:37:52.003 回答
1

load() 配置中声明的参数作为普通 HTTP 参数发送。在 C# 中,您必须发出 Request["start"] 和 Request["limit"] 来获取这些参数并将它们发送到您的数据层。在大多数情况下,您的数据库应该能够对返回的结果集/数据集进行分页,并且只将这些数据发送回 ExtJS。

于 2011-02-09T17:09:59.563 回答