javascript - 如何将分页添加到 extjs 4 网格?

标签 javascript extjs extjs4

我有一个像这样的商店,用于 extjs 网格

Ext.create('Ext.data.Store', {
    autoLoad : true,
    fields   : [
        {name: 'item_code', mapping: 'item_code', type: 'string'},
        {name: 'quantity', mapping: 'quantity', type: 'string'},
        {name: 'description', mapping: 'description', type: 'string'},
        {name: 'selling_price', mapping: 'selling_price', type: 'string'},
        {name: 'discount', mapping: 'discount', type: 'string'}
    ],
    storeId  : 'available_products',
    proxy    : {
        type            : 'ajax',
        actionMethods   : 'POST',
        url             : 'http://192.168.1.6/transactions/distribution_store',
        reader: {
            type: 'json',
            root: 'data'
        }
    }
});

我想给网格添加一个分页,但我想要这样

首先使用 json 加载所有数据并在客户端分页这些结果而不发送服务器请求。

这可能吗? 如何做到这一点?

问候

最佳答案

用于加载所有数据使用

var myData = [];
Ext.Ajax.request({
    url: 'http://192.168.1.6/transactions/distribution_store',
    method: 'POST',
    success: function(response){
        myData = Ext.decode(response.responseText);
    }
});

加载所有数据后,您可以使用 directFn 配置来模拟分页功能。查看我的回答here获取更多信息。并查看this demo也是。

更新

the solution doesn't work for ext js 4.1.1 . Can u provide an example for this version?

Doesn't work for ExtJS 4.2 either.

directFn 解决方案对我来说总是像是一个 hack。从 4.0.7 开始,不再需要使用 directFn。而是使用 Ext.ux.data.PagingMemoryProxy .演示是here

关于javascript - 如何将分页添加到 extjs 4 网格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7377283/

相关文章:

javascript - Div 标签不重新加载

javascript - ExtJS 网格速度慢,有 3000 多条记录

php - 为 ExtJS 树控件准备多维数组

javascript - ExtJs - 树拖放 - 将新拖动的节点设置为所选节点

javascript - 关于 Ext.define() 中 initComponent() 的最佳实践

Extjs 类系统静态

javascript - node.js 示例

javascript - 将 WordPress 帖子 ID 传递到另一个页面

javascript - Ext 3 教程代码与 Ext 4 不兼容

javascript - 使用 d3 创建泳道图