【extjs3.2】grid重新加载jsonstore后,点击grid上的分页组件,grid不刷新

页面上有个combobox,grid,grid上有个pageToolbar用于分页。页面加载时,会将json数据加载到grid和pageToolbar里。
点击分页(此时有4页数据),grid能够正常分页显示。此时选择combobox,重新查询load store,grid和pageToolbar进行更新(此时有2页数据),点击下一页grid数据[b]没有更新显示下一页数据[/b]。附核心代码:
根据combobox加载jsonstore,更新grid
[code="javascript"]
function reload(status){
var url = String.format(queryUri + 'status.json?status={0}',status);
var comboStore = createJsonStore(fields,url);
comboStore.load(
{
params:{start:0, limit:pageSize},
callback:function(r,options,success){
if(success == true){
var isNull = comboStore.getAt(0) == null;
if(isNull){
grid.store.removeAll();
grid.getView().refresh();
}else{
grid.store = comboStore;
var pageTool = grid.getBottomToolbar();
pageTool.updateInfo();
pageTool.bindStore(grid.store);
var topTool = grid.getTopToolbar();
topTool.bindStore(grid.store);
grid.getView().refresh();
}
}else{
Ext.MessageBox.alert("查询失败");
}
}
}
);
}
[/code]

[code="javascript"]
function createJsonStore(fileds,url) {
var jsonStore = new Ext.data.JsonStore({
fields : fileds,
root : 'root',
totalProperty : 'totalCount',
remoteSort : true,
proxy : new Ext.data.ScriptTagProxy({
url : url
})
});
return jsonStore;
}

[/code]

2个回答

[code="js"]
createPaging:function(pageSize,store){
this.option={
items:['-'],
store:store,
displayInfo:true,
pageSize:pageSize,
displayMsg:'{0}-{1}/{2}',
emptyMsg:KQinfo.msg.notRecords
};
if(this.dynamicPageSize){
var pageStore=new Ext.data.ArrayStore({
fields:['value','text'],
data:this.dynamicPageRecords
});
this.pageCombo=new Ext.form.ComboBox({
width:60,
mode:'local',
editable:false,
typeAhead:true,
value:pageSize,
store:pageStore,
valueField:'value',
displayField:'text',
selectOnFocus:true,
triggerAction:'all',
forceSelection:true
});
this.option.items.push({xtype:'displayfield',value:KQinfo.btn.dynamicPage},this.pageCombo);
}
var pagingBar=new Ext.PagingToolbar(this.option);
if(this.dynamicPageSize){
this.pageCombo.on('select',function(combo){
this.pageSize=combo.getValue();
pagingBar.pageSize=this.pageSize;
this.store.reload({params:{start:0,limit:this.pageSize}});
},this);
}
this.bbar=pagingBar;
delete this.option;
},
createStore:function(){
if(Ext.isEmpty(this.storeMapping))throw 'storeMapping undefined...';
var gridStore=new Ext.data.JsonStore({
root:"gridRows",
remoteSort:true,
url:this.actionUrl,
fields:this.storeMapping,
totalProperty:"totalCount"
});
gridStore.on('loadexception',function(s,r,response){
var status=response.status;
if(status=='401'||status=='500'||status=='404'){
parent.location.href=path+KQinfo.loginUrl;
}
},this);
gridStore.baseParams=this.params||{};
if(this.hasPage){
gridStore.load({params:{start:0,limit:this.pageSize}});
this.createPaging(this.pageSize,gridStore);
}else{
gridStore.load();
}
this.store=gridStore;
},
[/code]

lz的问题是ext自带的分页组件点击下一页数据没有刷新,需要手动刷新才能更新数据,并不是自定义分页组件的实现有问题,我想是combostore回调的时候有问题,但是直接看代码看不出来到底哪里有问题。 :oops:

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!