我在gridpanel的'initComponent'中初始化存储变量,如
initComponent: function() {
var store = Ext.create('Ext.data.Store', {
model: 'MyDataObject',
pageSize:_end,
proxy: {
type: 'ajax',
url: myurl,
reader: {
type: 'json',
totalProperty: 'total', // total data, see json output
root: 'results' // see json output
}
}
});
this.store = store;
this.callParent(arguments);
this.store.load({params:{start:_star, limit:_end}
});
我在分页工具栏中调用商店,如
dockedItems: [
{
xtype: 'pagingtoolbar',
dock: 'bottom',
store: this.store,
pageSize: _end,
displayInfo: true,
displayMsg: 'Displaying results {0} - {1} of {2}',
emptyMsg: 'No results'
}
]
在我的网格面板中仍然有数据,但我的底部显示“没有结果”之类的
我认为问题是 store:this.store,。我怎么能让它工作谢谢。
答案 0 :(得分:1)
您可以像这样定义商店
Ext.define('MyApp.store.MyDataStore', {
extend: 'Ext.data.Store',
model: 'MyDataObject',
storeId: 'myStoreId',
pageSize:_end,
proxy: {
type: 'ajax',
url: myurl,
reader: {
type: 'json',
totalProperty: 'total', // total data, see json output
root: 'results' // see json output
}
}
});
然后将myStoreId分配给网格面板和pagingtoolbar的store-config,框架(StoreManager)应该创建一个分配给它们的单个商店。
然后,您可以在商店中设置autoload = true,或者在网格的initComponent中创建新商店,然后手动加载。
答案 1 :(得分:0)
我在这里找到了解决方案 Remote paging grid in extjs 代码必须像:
this.store = store;
this.dockedItems = [{
xtype: 'pagingtoolbar',
store: this.store,
displayMsg: 'Displaying results {0} - {1} of {2}',
emptyMsg: 'No results',
dock: 'bottom',
displayInfo: true,
pageSize: 22
}];
this.callParent(arguments);
this.store.load({params:{start:0, limit:22}});
答案 2 :(得分:0)
我昨天遇到了这个陌生人的问题,在我解决这个问题之前,我想状态不是网格和分页栏中的商店同步,我花了很长时间用Firebug调试这个问题,换句话说商店不是同一个,它们只是一个商店的同一个实例,所以你可以用两种方式解决这个问题,第一个是创建商店的全局变量,两个都可以共享它,第二个是使用bindStore方法。例如支持你有网格扩展名如下
this.on('afterrender',function(){//this is grid itself
this.getBottomToolbar().bindStore(this.store)//set store of paggingtoolbar
},this);