jayg
6 Dec 2011, 2:16 PM
I'm trying to create my first ExtJS Model. I receive a JSON response like this:
{"RESPONSE":
{"TOKEN_ID":"12345",
"STATUS_CODE":0,
"FRUITS":
{"FRUIT":["Apple","Orange","Banana"]}
}
}
I'd like to check the STATUS_CODE value and display the list of fruits in a ComboBox.
I've tried dozens of Model variations, like this:
Ext.define('fruit.model.FruitList', {
extend: 'Ext.data.Model',
fields: [
{name: 'statusCode', mapping: 'STATUS_CODE', type: 'string' }
],
hasMany: {model: 'fruit.model.Fruit', name: 'fruits', associationKey: 'FRUITS', reader: {type: 'json', record: 'FRUIT'}}
});
Ext.define('fruit.model.Fruit', {
extend: 'Ext.data.Model',
fields: [
{name: 'name', mapping: function(v){return v;}}
],
belongsTo: 'fruit.model.FruitList'
});
without success. Any suggestions how to model this? Also, how would I use the "nested" store in a ComboBox? Thanks!
{"RESPONSE":
{"TOKEN_ID":"12345",
"STATUS_CODE":0,
"FRUITS":
{"FRUIT":["Apple","Orange","Banana"]}
}
}
I'd like to check the STATUS_CODE value and display the list of fruits in a ComboBox.
I've tried dozens of Model variations, like this:
Ext.define('fruit.model.FruitList', {
extend: 'Ext.data.Model',
fields: [
{name: 'statusCode', mapping: 'STATUS_CODE', type: 'string' }
],
hasMany: {model: 'fruit.model.Fruit', name: 'fruits', associationKey: 'FRUITS', reader: {type: 'json', record: 'FRUIT'}}
});
Ext.define('fruit.model.Fruit', {
extend: 'Ext.data.Model',
fields: [
{name: 'name', mapping: function(v){return v;}}
],
belongsTo: 'fruit.model.FruitList'
});
without success. Any suggestions how to model this? Also, how would I use the "nested" store in a ComboBox? Thanks!