Ext点击上下页面时,绑定当前查询的条件,否则分页错误
第一种方式在改变操作store时调用该段代码:
var store = this.getStore();
//先删除先前的参数
for (var key in store.baseParams) {
if (key && key.indexOf('userId') != -1) {
delete store.baseParams[key];
}
if (key && key.indexOf('ipArea') != -1) {
delete store.baseParams[key];
}
if (key && key.indexOf('mobileBrandId') != -1) {
delete store.baseParams[key];
}
if (key && key.indexOf('cityId') != -1) {
delete store.baseParams[key];
}
if (key && key.indexOf('startTime') != -1) {
delete store.baseParams[key];
}
if (key && key.indexOf('endTime') != -1) {
delete store.baseParams[key];
}
}
// 绑定查询参数到store,否则点击分页时会出现无参数情况,会导致下一页的信息结果有误
if (userId)
store.setBaseParam('userId', userId);
if (ipArea)
store.setBaseParam('ipArea', ipArea);
if (endTime)
store.setBaseParam('endTime', endTime);
if (cityId)
store.setBaseParam('cityId', cityId);
if (startTime)
store.setBaseParam('startTime', startTime);
if (mobileBrandId)
store.setBaseParam('mobileBrandId', mobileBrandId);
第二种方式用触发事件:
在定义grid时添加该事件
var self = this;
var _store = new Ext.data.Store({
proxy : new Ext.data.HttpProxy({
url : 'xxx'
}),
reader : new Ext.data.JsonReader({
idProperty : 'id',
root : 'data',
fields : [{
name : 'id',
type : 'string'
}
}]
}),
writer : new Ext.data.JsonWriter()
});
var wordText = new Ext.form.TextField({
fieldLabel : "基础词",
name : "word",
allowBlank : true,
anchor : '96%'
});
_store.on('beforeload', function() {
var word = self.wordText.getValue();
Ext.apply(this.baseParams, {
word : word
});
scope : self
});
}); 1 楼 Java_Eye007 2011-11-22 _store.on('beforeload', function() {
var word = self.wordText.getValue();
Ext.apply(this.baseParams, {
word : word
});
scope : self
});
'beforeload' , 首次分页应该不加载查询条件吧?