为什么我的 ExtJS GridPanel 不关注 limit 参数?

发布于 2024-10-17 01:36:19 字数 1152 浏览 11 评论 0原文

我有一个 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 条记录。 我在这里遗漏了一些明显的东西吗?

I have a 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

I then call Load on this store with the following:

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

I have a grid to display this data in:

    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}
    ]
 });

I expected this to only display 25 records/rows per page. however it only displays one page with the total 160 records on this page.
Am I missing something obvious here?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

年华零落成诗 2024-10-24 01:36:20

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

You are missing the totalProperty for the Store/JsonReader. This should be the total number of records, the paging toolbar needs to know this to calculate the number of pages, etc. Also Your server needs to send back the correct page and the total Result count. Looks like your server is sending back all the records and is ignoring the start and limit parameters.

心舞飞扬 2024-10-24 01:36:20

shane87,

简而言之,您可能在这里忽略的“明显”事情是服务器有责任检测/读取启动和限制并仅发回“限制”数量的记录

否则,您的客户端代码看起来不错,除了 totalProperty 您可能需要按照 Robby 的 答案如下。

shane87,

In short, the "obvious" thing that you may be missing here is the fact that it is the server's responsibility to detect/read start and limit and send back only 'limit' number of records.

Otherwise, your client code looks OK, except for the totalProperty that you may want to check as mentioned by Robby's answer below.

︶葆Ⅱㄣ 2024-10-24 01:36:20

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

Params declared in the load() config are sent as plain HTTP params. In C# you would have to issue a Request["start"] and a Request["limit"] to get those params and them send them along to your data tier. In most cases your database should be able to page returned resultsets/datasets and send only that data back to ExtJS.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文