覆盖下一个和上一个按钮分页工具栏sencha extjs 4.1
我的应用程序中的分页工具栏有问题。我的存储由一个PHP脚本填充,该脚本将MySQL数据库表转换为JSON数据 在我的窗口中,我有一个带有表单的面板,我用它来过滤网格。所有“过滤器”都作为参数传递到覆盖下一个和上一个按钮分页工具栏sencha extjs 4.1,extjs,overriding,paging,Extjs,Overriding,Paging,我的应用程序中的分页工具栏有问题。我的存储由一个PHP脚本填充,该脚本将MySQL数据库表转换为JSON数据 在我的窗口中,我有一个带有表单的面板,我用它来过滤网格。所有“过滤器”都作为参数传递到store.load()调用中,PHP脚本完成查询并返回数据 我的问题是,当我有一些过滤器,我点击页面工具栏的“下一步”按钮时,我的过滤器就会消失,并且存储区会在没有额外参数的情况下加载。如何在nextPage()/prevPage()调用中发送额外的参数 编辑: 我使用store解决了这个问题。在('
store.load()
调用中,PHP脚本完成查询并返回数据
我的问题是,当我有一些过滤器,我点击页面工具栏的“下一步”按钮时,我的过滤器就会消失,并且存储区会在没有额外参数的情况下加载。如何在nextPage()/prevPage()调用中发送额外的参数
编辑:
我使用store解决了这个问题。在('beforeload')
上,我的解决方案如下:
store.on('beforeload', function(store, operation, opts){
operation.params={
// yuor params here
param1: param1Value,
param2: param2Value
};
}, this);
您需要覆盖分页工具栏的moveNext和movePrevious方法,在这些方法中,您可以传递一个对象,其中包含您需要传递给PHP的所有自定义参数
/**
* Move to the next page, has the same effect as clicking the 'next' button.
*/
moveNext : function(){
var me = this,
total = me.getPageData().pageCount,
next = me.store.currentPage + 1;
if (next <= total) {
if (me.fireEvent('beforechange', me, next) !== false) {
me.store.nextPage({
// all the custom params should go here
param1 : 'value1'
});
}
}
}
参考:
我不知道你是否找到了答案,但我也遇到了同样的问题,以下是我找到的答案 希望能有帮助 当您使用参数进行调用时,只能调用一次。在以前的版本中,Sencha告诉我使用baseParams,但我在新版本中找不到它。因此,我使用代理的extraParams如下: 这是我用来过滤数据的表单按钮
text: 'Filter',
handler: function() {
/*
get the form
get a record object and set its data
*/
var form = this.up('form').getForm();
var record = form.getRecord();
form.updateRecord(record);
for(name in record.data){
if (record.data.hasOwnProperty(name))
envelopeStore.setExtraParam(name, record.data[name]);
}
/*
envelopeStore.getProxy().extraParams = record.data;
*I have some constant params so I needed to add them in a loop as above
*you can simply use this
*/
envelopeGrid.child('pagingtoolbar').moveFirst();
/*
do not load store data. It does not change paging. go to first page instead
*/
}
不起作用,我使用了一个参数来尝试此解决方案,当我单击“下一步”时,将重新加载没有参数的存储。我在上面的问题中发布了我的代码
text: 'Filter',
handler: function() {
/*
get the form
get a record object and set its data
*/
var form = this.up('form').getForm();
var record = form.getRecord();
form.updateRecord(record);
for(name in record.data){
if (record.data.hasOwnProperty(name))
envelopeStore.setExtraParam(name, record.data[name]);
}
/*
envelopeStore.getProxy().extraParams = record.data;
*I have some constant params so I needed to add them in a loop as above
*you can simply use this
*/
envelopeGrid.child('pagingtoolbar').moveFirst();
/*
do not load store data. It does not change paging. go to first page instead
*/
}