ExtJS的5格店/视图模型绑定:不能修改转空店 [英] ExtJs 5 grid store/viewmodel binding: Cannot modify ext-empty-store
问题描述
我拉我的头发就这一个...
I'm pulling my hair out on this one...
我有一些网格,一家商店和一个视图模型视图。我需要在不同的网格店里的不同版本的过滤,所以我想每个过滤存储绑定到一个网格。现在,我甚至不能得到一个店在网格中加载在首位...
I have a view with some grids, a store and a viewModel. I need different filtered versions of the store in different grids, so I'm trying to bind each filtered store to a grid. Now I can't even get a store to load in a grid in the first place...
下面是我的code样子:
Here's what my code looks like:
商品
Ext.define('My.store.Admin.Kinder', {
extend: 'Ext.data.Store',
model: 'My.model.Kind',
storeId: 'adminKinderStore',
alias: 'store.adminKinder',
proxy: {
type: 'ajax',
method: 'post',
url: '/getKinder',
reader: {
type: 'json',
rootProperty: 'kinder'
}
}
});
视图模型:
Ext.define('My.model.kindViewModel', {
extend: 'Ext.app.ViewModel',
alias: 'viewmodel.kindViewModel',
requires: [
'My.model.Kind',
'My.store.Admin.Kinder'
],
view: 'kindView',
stores: {
warteliste: {
type: 'adminKinder'
}
}
});
查看:
Ext.define('My.view.Admin.kinder', {
extend: 'Ext.panel.Panel',
alias: 'widget.kindView',
id: 'kinder-panel',
requires: [
'My.view.Admin.kindController',
'My.model.kindViewModel'
],
controller: 'kind',
border: false,
maxWidth: 960,
session: My.session,
viewModel: {
type: 'kindViewModel'
},
initComponent: function() {
this.activeTab = 'warteliste-tab';
this.callParent();
},
items: [
{
xtype: 'grid',
id: 'warteliste-grid',
bind: {
store: '{warteliste}'
},
border: false,
margin: '0 0 20px 0',
selModel: {
allowDeselect: true
},
columns: [
// some grid columns
],
listeners: {
afterRender: function(grid) {
grid.store.load();
}
}
}]
});
我得到一个错误信息无法修改转空店,这必然意味着这家店是(还)没有约束时store.load()被调用的一个AfterRender监听器。
奇怪的是,当我CONSOLE.LOG网格,这家店是存在的。当我CONSOLE.LOG grid.store,一个空的商店被返回。
I get an error message "Cannot modify ext-empty-store", which must mean that the store is not (yet) bound when store.load() is called in the afterRender listener. Strange thing is, when I console.log the grid, the store is there. When I console.log grid.store, an empty store is returned.
推荐答案
我得到了一个AfterRender事件同样的问题,并没有得到来自电网的商店像
I got the same issue in afterRender event and solved it by not getting the store from the grid like
grid.store.load();
但是从视图模型(的ViewController范围内):
but from the ViewModel (ViewController scope):
this.getViewModel().getStore('{warteliste}').load();
这篇关于ExtJS的5格店/视图模型绑定:不能修改转空店的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!