Lets say I have an object that I'd like to map to a model:
In my model, I'm trying to do this:
etc.
Code:
{
name: 'thisWeekObject',
day: [
{
name: 'Sunday',
value: 0
},
{
name: 'Monday',
value: 4
},
{
name: 'Tuesday',
value: 3.2
},
{
name: 'Wednesday',
value: 4.1
},
{
name: 'Thursday',
value: 1
},
{
name: 'Friday',
value: 0.2
},
{
name: 'Saturday',
value: 0
},
]
}
In my model, I'm trying to do this:
Code:
Ext.define('MyProj.model.Week', {
extend: 'Ext.data.Model',
config: {
fields: [
{
mapping: 'name',
name: 'name'
},
{
mapping: 'day[0].name',
name: 'day0name'
},
{
mapping: 'day[0]value',
name: 'day0value'
},
{
mapping: 'day[1].name',
name: 'day1name'
},
{
mapping: 'day[1].value',
name: 'day1value'
},
{
mapping: 'day[2].name',
name: 'day2name'
},
{
mapping: 'day[2].value',
name: 'day2value'
},
etc.
I've tried that, but unfortunately am still getting undefined for all my day fields.
Any suggestions?
I could use convert, but I need to be able to write to these fields as well.
Any help is appreciated.
Aucun commentaire:
Enregistrer un commentaire