var departName, industry, pointDepart;//用于列表的全局变量
var company_food_grid = new Ext.grid.GridPanel({
ds: ds,
cm: cm,
805,
height: 573,
frame: true,
title: '企业信息',
bbar: new Ext.PagingToolbar({
pageSize: 20,
store: ds,
displayInfo: true,
displayMsg: '显示第 {0} 条到 {1} 条记录,一共 {2} 条',
emptyMsg: "没有记录"
}),
tbar: ['单位名称:', {
xtype: 'textfield',
120,
id: 'departName'
}, '-', '行业:', {
xtype: 'textfield',
120,
id: 'industry'
}, '-', '监测单位:', {
xtype: 'textfield',
id: 'pointDepart'
}, '-', '->', '-', {
xtype: 'button',
text: '查询',
handler: function(){
company_food_grid.getStore().removeAll();
departName = Ext.getCmp("departName").getValue();
industry = Ext.getCmp("industry").getValue();
pointDepart = Ext.getCmp("pointDepart").getValue();
ds.load({
params: {
start: 0,
limit: 20,
departName: departName,
industry: industry,
pointDepart: pointDepart
}
});
}
}, '-']
});
var company_food_grid = new Ext.grid.GridPanel({
ds: ds,
cm: cm,
805,
height: 573,
frame: true,
title: '企业信息',
bbar: new Ext.PagingToolbar({
pageSize: 20,
store: ds,
displayInfo: true,
displayMsg: '显示第 {0} 条到 {1} 条记录,一共 {2} 条',
emptyMsg: "没有记录"
}),
tbar: ['单位名称:', {
xtype: 'textfield',
120,
id: 'departName'
}, '-', '行业:', {
xtype: 'textfield',
120,
id: 'industry'
}, '-', '监测单位:', {
xtype: 'textfield',
id: 'pointDepart'
}, '-', '->', '-', {
xtype: 'button',
text: '查询',
handler: function(){
company_food_grid.getStore().removeAll();
departName = Ext.getCmp("departName").getValue();
industry = Ext.getCmp("industry").getValue();
pointDepart = Ext.getCmp("pointDepart").getValue();
ds.load({
params: {
start: 0,
limit: 20,
departName: departName,
industry: industry,
pointDepart: pointDepart
}
});
}
}, '-']
});
代码如上:点击查询按钮的时候数据重新加载了,但是分页上显示的数据也显示了,但是当我点击下一页的箭头的时候,发现数据又回到了初始的状态而不是查询后的结果数据,在网上找了一下在store重新加载的时候添加一个beforeload监听事件
ds.on("beforeload", function(){
Ext.apply(this.baseParams, {
departName: departName,
industry: industry,
pointDepart: pointDepart
});
Ext.apply(this.baseParams, {
departName: departName,
industry: industry,
pointDepart: pointDepart
});
})