You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ext Grid PagingToolbar显示但无法实现分页功能求助

Ext Grid分页失效问题排查与解决

问题概况

Ext Grid已添加PagingToolbar插件,插件可见但无法触发分页操作;系统内其他Grid使用完全相同配置时分页功能正常;将代理类型从rest-new-api改为rest后问题仍存在,后端已正确配置接收分页参数。

核心排查点与解决方案

1. 配置Reader的总记录数字段

PagingToolbar需要获取总记录数才能计算分页逻辑,当前Model的Reader仅配置了rootProperty,缺少读取后端总条数的totalProperty配置。

修改Model中Proxy的Reader配置,添加totalProperty(字段名需与后端返回结构匹配,示例假设后端总条数在data.total_items):

proxy: {
    type: 'rest',
    url: `${Ext.manifest.apiUrl}/siem/agents`,
    reader: {
        type: 'json',
        rootProperty: 'data.affected_items',
        totalProperty: 'data.total_items' // 新增:指定总记录数字段
    },
    writer: {
        type: 'json',
    },
}

2. 开启远程分页

默认情况下Ext的Rest代理未开启远程分页,导致Store不会向后端传递分页参数,仅在本地处理数据。

在ViewModel的Store配置中添加remotePaging: true:

stores: {
    agents: {
        model: 'SIEM.model.Agents',
        autoLoad: true,
        pageSize: 9,
        remotePaging: true, // 开启远程分页,强制传递分页参数
        // remoteSort: false 保持原有配置即可
    }
}

或直接在Model的Proxy中配置:

proxy: {
    type: 'rest',
    url: `${Ext.manifest.apiUrl}/siem/agents`,
    remotePaging: true, // 开启远程分页
    reader: {
        type: 'json',
        rootProperty: 'data.affected_items',
        totalProperty: 'data.total_items'
    },
    writer: {
        type: 'json',
    },
}

3. 匹配后端分页参数名

如果后端接收的分页参数名与Ext默认值(page、limit)不一致,需在Proxy中显式配置参数映射:

proxy: {
    type: 'rest',
    url: `${Ext.manifest.apiUrl}/siem/agents`,
    remotePaging: true,
    pageParam: 'page',       // 后端接收的页码参数名,默认是page
    limitParam: 'per_page',  // 后端接收的每页条数参数名,默认是limit
    // startParam: 'start'   // 如果后端使用start索引而非page页码,启用此项
    reader: {
        type: 'json',
        rootProperty: 'data.affected_items',
        totalProperty: 'data.total_items'
    },
    writer: {
        type: 'json',
    },
}

4. 检查刷新按钮的加载逻辑

确认loadMainStore方法是否正确触发Store的分页加载,避免清空分页参数:

// 示例正确加载逻辑
loadMainStore: function() {
    const store = this.getViewModel().getStore('agents');
    store.loadPage(1); // 加载第一页,保留分页参数
    // 或直接store.load(),自动携带当前分页参数
}

内容的提问来源于stack exchange,提问作者Joclelson

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.26 05:06:01