如何向 extjs 4 网格添加分页?

发布于 2024-12-03 17:47:13 字数 874 浏览 0 评论 0原文

我有一个像这样的商店,我用于 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 加载所有数据,然后在客户端对这些结果进行分页,而不发送服务器请求。

是否可以? 怎么办?

问候

I have a store like this which i used for a extjs grid

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

I want to add a paging to grid but i want it like this

first load all the data with json and paging those results at client side without sending server requests.

is it possible?
how to do this?

Regards

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

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

发布评论

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

评论(1

情栀口红 2024-12-10 17:47:13

加载所有数据时使用

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配置来模拟分页功能。在此处查看我的答案< /a> 了解更多信息。也可以查看此演示

更新

该解决方案不适用于 ext js 4.1.1 。你能提供这个版本的例子吗?

也不适用于 ExtJS 4.2。

directFn 解决方案对我来说总是像是一个黑客。从 4.0.7 开始,无需使用 directFn。而是使用 Ext.ux.data.PagingMemoryProxy 。演示位于此处

For loading all data use

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

When all data is loaded you can utilize directFn config for emulating paging functionality. Check out my answer here for more info. And check out this demo too.

UPDATE

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 solution always seemed like a hack to me. Since 4.0.7 there is no need to use directFn. Instead use Ext.ux.data.PagingMemoryProxy. The demo is here

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