我正在开发一个 ExtJS 4.2 项目,我想在其中使用分页工具栏来浏览图像。
当我打开窗口时,所有图像都是正确的,但是当我单击下一个按钮查看下一个图像时,结果为空。这是因为参数Id没有传递到后端系统。
我在其他线程中看到像 baseParams
这样的选项,但它们不在文档中并且不起作用。
//My Store Class
Ext.define('App.store.Images', {
extend: 'Ext.data.Store',
model: 'App.model.Images',
autoLoad: false,
autoSync: false,
storeId: 'Images',
pageSize: 8,
proxy: {
type: 'ajax',
url: '/getImages',
reader: {
type: 'json',
root: 'images',
totalProperty: 'total'
}
}
});
// This code is execute when i open the Window
var imagesStore = Ext.StoreManager.get('Images');
imagesStore.on('load', buildContent);
imagesStore.load({
params: {
id: record.get('id'),
start: 0,
limit: 8
}
});
哪里可以定义附加参数?
最佳答案
事实上,您可以在存储代理上定义 extraParams。您可以在加载方法调用之前执行此操作:
Ext.apply(store.getProxy().extraParams, {
'yourId': yourId
});
或在您的代理配置中:
proxy: {
type: 'ajax',
url: '/getImages',
reader: {
type: 'json',
root: 'images',
totalProperty: 'total'
}
extraParams: {
'yourId': yourId
}
}
关于javascript - 带有附加参数的 Extjs 分页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25203596/