0
Extjs4 Store類的data屬性描述了一個對象層次結構。我把它作爲我店的數據屬性,因爲數據是靜態的;不需要額外撥打服務器來填充商店。我以前做過這個,但是這次我的許多關係沒有被填充。我嘗試了多種方法來解決這個問題,但我很難過。你會看看它,看看我錯過了什麼嗎?Extjs4 hasMany()關係無法從商店的「數據」屬性中加載
對象的關係是:MarineForm has MarineFormSections which has 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'
}
});
的的hasMany類:
Ext.define('MAP.model.MarineFormSection', {
extend: 'Ext.data.Model',
fields: [
'id',
{name: 'name', type: 'string'}
],
hasMany: {
model: 'MAP.model.MarineFormField',
name: 'formFields'
}
});
所述的hasMany的的hasMany類(第三層嵌套)
Ext.define('MAP.model.MarineFormField', {
extend: 'Ext.data.Model',
fields: [
'name',
{name:'allowBlank', type:'boolean'},
'fieldLabel',
'xtype',
//next ones are for comboboxes. Not used all the time. -jg
'store',
'valueField',
'displayField'
]
});
下面是從內鉻查詢存儲的輸出:
rootStore = Ext.getStore('MarineFormStore') // -> the store
sections = rootStore.getAt(0).sections() // -> hasMany store
sections.getCount() // -> 0
我試着:
- Removi納克
MarineFormField hasMany
塊MarineFormFields
- 在根存儲的
data
字段中添加一個ID,MarineFormField
- 三重檢查任何錯別字
感謝您抽出寶貴的時間!
就是這樣!謝謝你救了我一些痛苦和悲傷。 –