Extjs4 分页存储未更改
我正在使用重新配置函数来更改 小组形式 请参见下面我编写的代码Extjs4 分页存储未更改,extjs4,Extjs4,我正在使用重新配置函数来更改 小组形式 请参见下面我编写的代码 var newStore = Ext.create('Ext.data.Store', { fields: tmpFields, pageSize: itemsPerPage, proxy: { type: 'ajax', url: getDataWithPageURL, } }); glo
var newStore = Ext.create('Ext.data.Store', {
fields: tmpFields,
pageSize: itemsPerPage,
proxy: {
type: 'ajax',
url: getDataWithPageURL,
}
});
globalStore = newStore.load({
params: {
start: 0,
limit: itemsPerPage
}
});
grid.reconfigure(globalStore, tmpColumns);
代码正在运行,并且数据已更改。
但分页和总计确实显示了旧数据
请帮助。我认为这是重新配置功能中的错误 所以我创建了分页栏并再次添加。请参阅下面的代码
var PagingBar = Ext.create('Ext.PagingToolbar', {
pageSize: itemsPerPage,
store: globalStore,
dock: 'bottom',
displayInfo: true
});
grid.removeDocked(grid.getDockedItems()[1]);
grid.addDocked(PagingBar);
在ExtJS中,
PagingToolbar
与给定的存储密切合作,这就是为什么没有事件侦听器连接到reconfigure
,因为reconfigure
是在Ext.panel.Table
中定义的
因此,另一种解决方案是在触发reconfigure
时重新绑定存储,即:
Ext.define('NS.toolbar.Paging', {
extend: 'Ext.toolbar.Paging',
initComponent: function() {
var me = this;
me.callParent();
me.on('afterrender', function() {
me.ownerCt.on('reconfigure', function() {
me.bindStore(me.ownerCt.store || 'ext-empty-store', true);
});
});
}
});
在呈现了PagingToolbar
之后,我们将一个函数绑定到事件reconfigure
,这样每当发生reconfigure
时,您就可以在分页工具栏中重新绑定存储
经过测试,效果良好
干杯