PDA

View Full Version : Adding/removing sublist elements



gp40
24 Jan 2011, 8:00 PM
I have what I believe to be a simple problem. I need to add/remove "Item" elements but for the life of me I can't figure out the syntax to do so. I'd expect something like activeItem.<?>.add( {product: 'ZTC', quantity: '15'} ).
Thanks in advance. /Greg



...
var opp = Ext.regModel('Opp', {
fields: [
{name: 'first', type: 'string'},
{name: 'last', type: 'string'}
],
hasMany: {model: 'Item', name: 'items'}
});
Ext.regModel("Item", {
fields: [
{name: 'product', type: 'string'},
{name: 'quantity', type: 'string'}
],
belongsTo: 'Opp'
});
...


JSON


[
{
"first": "Greg",
"last": "Preston",
"items": [
{ "product": "MTC",
"quantity": "5" },
{ "product": "XTC",
"quantity": "1" }
]
}
]