您需要覆盖分页工具栏的 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'
});
}
}
}
这将很容易解决您当前的问题,但是如果您想要一个通用修复程序,每次从商店获取上一页/下一页时,商店都会提供这些自定义参数,那么您可以覆盖 loadPage 方法并在那里添加自定义参数
loadPage: function(page, options) {
var me = this;
me.currentPage = page;
// add your custom params
options = Ext.apply({
param1 : 'value1'
}, options);
// Copy options into a new object so as not to mutate passed in objects
options = Ext.apply({
page: page,
start: (page - 1) * me.pageSize,
limit: me.pageSize,
addRecords: !me.clearOnPageLoad
}, options);
if (me.buffered) {
return me.loadToPrefetch(options);
}
me.read(options);
}
参考:
http://docs.sencha.com/ext-js/4-1/source/Paging.html#Ext-toolbar-Paging
http://docs.sencha.com/ext-js/4-1/source/Store.html#Ext-data-Store-method-nextPage