Model Extjs4没有从存储加载多个()关系';s';数据';财产
Extjs4存储类的data属性描述了对象层次结构。我把它作为我的存储的数据属性,因为数据是静态的;无需额外调用服务器来填充存储。我以前也这样做过,但这次我的hasMany关系没有得到改善。我已经尝试了各种方法来解决这个问题,但我被难倒了。你能看看我有没有遗漏什么吗 对象之间的关系是:Model Extjs4没有从存储加载多个()关系';s';数据';财产,model,extjs4,extjs,Model,Extjs4,Extjs,Extjs4存储类的data属性描述了对象层次结构。我把它作为我的存储的数据属性,因为数据是静态的;无需额外调用服务器来填充存储。我以前也这样做过,但这次我的hasMany关系没有得到改善。我已经尝试了各种方法来解决这个问题,但我被难倒了。你能看看我有没有遗漏什么吗 对象之间的关系是:MarineForm有MarineFormSections,后者有MarineFormFields 存储及其数据属性: Ext.define('MAP.store.MarineFormStore', { e
MarineForm有MarineFormSections,后者有MarineFormFields
存储及其数据属性:
Ext.define('MAP.store.MarineFormStore', {
extend: 'Ext.data.Store',
model: 'MAP.model.MarineForm',
data:[
{
species:'Mackerel',
gear:null,
sections:[
{
name:'General Info',
formFields:[
{
xtype:'textfield',
name:'firstField',
allowBlank:false,
fieldLabel:'First Field'
}
]
}
]
}
]
});
Ext.define('MAP.model.MarineForm', {
extend: 'Ext.data.Model',
fields: [
{name: 'species', type: 'string'},
{name: 'gear', type: 'string'}
],
hasMany: {
model: 'MAP.model.MarineFormSection',
name: 'sections'
}
});
Ext.define('MAP.model.MarineFormSection', {
extend: 'Ext.data.Model',
fields: [
'id',
{name: 'name', type: 'string'}
],
hasMany: {
model: 'MAP.model.MarineFormField',
name: 'formFields'
}
});
根模型:
Ext.define('MAP.store.MarineFormStore', {
extend: 'Ext.data.Store',
model: 'MAP.model.MarineForm',
data:[
{
species:'Mackerel',
gear:null,
sections:[
{
name:'General Info',
formFields:[
{
xtype:'textfield',
name:'firstField',
allowBlank:false,
fieldLabel:'First Field'
}
]
}
]
}
]
});
Ext.define('MAP.model.MarineForm', {
extend: 'Ext.data.Model',
fields: [
{name: 'species', type: 'string'},
{name: 'gear', type: 'string'}
],
hasMany: {
model: 'MAP.model.MarineFormSection',
name: 'sections'
}
});
Ext.define('MAP.model.MarineFormSection', {
extend: 'Ext.data.Model',
fields: [
'id',
{name: 'name', type: 'string'}
],
hasMany: {
model: 'MAP.model.MarineFormField',
name: 'formFields'
}
});
有很多类:
Ext.define('MAP.store.MarineFormStore', {
extend: 'Ext.data.Store',
model: 'MAP.model.MarineForm',
data:[
{
species:'Mackerel',
gear:null,
sections:[
{
name:'General Info',
formFields:[
{
xtype:'textfield',
name:'firstField',
allowBlank:false,
fieldLabel:'First Field'
}
]
}
]
}
]
});
Ext.define('MAP.model.MarineForm', {
extend: 'Ext.data.Model',
fields: [
{name: 'species', type: 'string'},
{name: 'gear', type: 'string'}
],
hasMany: {
model: 'MAP.model.MarineFormSection',
name: 'sections'
}
});
Ext.define('MAP.model.MarineFormSection', {
extend: 'Ext.data.Model',
fields: [
'id',
{name: 'name', type: 'string'}
],
hasMany: {
model: 'MAP.model.MarineFormField',
name: 'formFields'
}
});
hasMany的hasMany类(第三层嵌套)
以下是在Chrome中查询存储的输出:
rootStore = Ext.getStore('MarineFormStore') // -> the store
sections = rootStore.getAt(0).sections() // -> hasMany store
sections.getCount() // -> 0
我试过:
MarineFormField有许多MarineFormFields的block
MarineFormField
数据
字段中三次检查是否有任何输入错误谢谢你抽出时间 在我看来,您缺少的只是存储配置中的以下内容(或者您可能只是忘记加载存储):
包含此更改的代码基本上都是您的代码,而且似乎工作正常。就是这样!谢谢你帮我省去了一些痛苦和悲伤。