问题描述
我想使用一个连锁到全球商店的商店,
,但在启动后,我给出了js警告:
Ext.data.Store创建没有模型
,我看不到任何数据。 >
以下是我的代码:
全局用户存储
Ext.define('App.store.UserStore',{
extends:'App.store.AjaxReadyStore',
需要:['App.model.UserModel'],
model:'App.model.UserModel',
autoLoad:false,
id:'UserStore',
别名:'store.UserStore',
构造函数:function(){
this.callParent(arguments);
this.proxy.api = {
create:'api / v1 / users',
read:'api / v1 / users',
update:'api / v1 / users',
destroy:'api / v1 / users'
};
this.readAndLoad();
}
});
ViewModel
Ext.define('App.view.tasktemplate.TaskTemplateModel',{
extends:'Ext.app.ViewModel',
alias:'viewmodel.tasktemplate ',
store:{
owner:{
source:'UserStore'
}
}
});
查看
Ext.define('App.view.tasktemplate.TaskTemplateOwnerList',{
extends:'App.view.pool.grid.GridWithAction',
xtype: 'tasktemplateownerlist',
store:{
bind:'{owner}'
},
});
将您的视图代码更改为 -
Ext.define('App.view.tasktemplate.TaskTemplateOwnerList',{
extends:'App.view.pool.grid。 GridWithAction',
xtype:'tasktemplateownerlist',
bind:{
store:'{owner}'
}
});
商店装订:
bind:{
store:'{owner}'
}
当您执行
store:{
bind:'{owner}'
}
在您的视图内 - StoreManager通过商店配置的值进行查找,通常期望一个字符串或数组的字符串(存储名称),但它看到它不是一个字符串,而是一个对象,所以它创建一个'Ext.data.Store'的实例,通过{bind:'{owner}'}作为config - >所以你实际上得到了一个没有模型关联的Store类的实例。
商店:
I want to use a store that in chained to global store,but after launch I gives js warning:
Ext.data.Store created with no model
and i cannot see any data.
Here is my code:
Global UserStore
Ext.define('App.store.UserStore',{
extend : 'App.store.AjaxReadyStore',
requires : ['App.model.UserModel'],
model : 'App.model.UserModel',
autoLoad : false,
id : 'UserStore',
alias : 'store.UserStore',
constructor : function() {
this.callParent(arguments);
this.proxy.api= {
create : 'api/v1/users',
read : 'api/v1/users',
update : 'api/v1/users',
destroy : 'api/v1/users'
};
this.readAndLoad();
}
});
ViewModel
Ext.define('App.view.tasktemplate.TaskTemplateModel', {
extend : 'Ext.app.ViewModel',
alias : 'viewmodel.tasktemplate',
stores : {
owner: {
source : 'UserStore'
}
}
});
View
Ext.define('App.view.tasktemplate.TaskTemplateOwnerList',{
extend : 'App.view.pool.grid.GridWithAction',
xtype : 'tasktemplateownerlist',
store: {
bind : '{owner}'
},
});
Change your view code to this -
Ext.define('App.view.tasktemplate.TaskTemplateOwnerList',{
extend : 'App.view.pool.grid.GridWithAction',
xtype : 'tasktemplateownerlist',
bind: {
store : '{owner}'
}
});
Store Binding:
bind: {
store : '{owner}'
}
It's actually interesting when you do
store: {
bind : '{owner}'
}
inside your view - The StoreManager does a lookup with the value of the store config, usually expecting a string or array of strings (store name) but it sees that it's not a string but an object so it creates a instance of 'Ext.data.Store' passing {bind:'{owner}'} as config -> so you actually get an instance of the Store class with no models associated. store:
这篇关于Extjs链接存储到ViewModel中的GlobalStore的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!