我有一个像这样的商店,用于 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/