PDA

View Full Version : Problem with grouped association JSON list



Necros
12 Aug 2011, 5:59 AM
Problem with following:

27465
This is fixed too: http://www.sencha.com/forum/showthread.php?128503-List-not-preparing-association-data-when-List.grouped-true (does not work without it)

My Store:

Ext.regStore("GetCart",{ model: "CartGroup",
getGroupString : function(record) {
return record.get('Summary');
},
proxy: {
type: 'ajax',
url : 'json/call/index.php',
reader: {
type: 'json',
root: 'getCartContents.Grouping'
},
extraParams:{
method:'getCartContents'
}
}
});


My Models:

Ext.regModel("CartGroup", {
fields: [
'Title', 'Summary', 'Total'
],
hasMany : {model: 'GetCart', name: 'CartContents'}
});


Ext.regModel("GetCart", {
fields : [
{ name: "lineID", type: 'int'},
{ name: "prodDesc", type: 'string'},
{ name: "productID", type: 'string'},
{ name: "prodQty" ,type: 'int'},
{ name: "unitPrice", type: 'int'},
{ name: "usageCode", type: 'string'},
{ name: "usageDesc", type: 'string'},
{ name: "usageSequence", type: 'string'},
{ name: "usageSection", type: 'int'}
],
belongsTo: 'CartGroup'
});


Other:

{
xtype: 'list',
store: Ext.getStore('GetCart'),
itemTpl: '<tpl for="CartContents">{prodDesc}{prodQty}{unitPrice}{usageSection}</tpl>',
grouped: true,
listeners: {
selectionchange: function(selectionModel, selections) {
console.log(selections);
showroom.controllers.modifycard.onOpen(selections[0], selectionModel);
}
}
}

JSON:

{"getCartContents": {
"Grouping": [
{
"Title": "Estimating",
"Summary": "1x ",
"Total": 0.0,
"CartContents": [
{
"lineID": 1000,
"prodDesc": "1 Each Product line 1 dsc description line 2 .....x",
"productID": "1",
"prodQty": 1,
"unitPrice": 0.0,
"usageCode": "",
"usageDesc": "",
"usageSequence": "",
"usageSection": 0
}
]
},
{
"Title": "WC",
"Summary": "1x Bath, 1x Hardware",
"Total": 0.0,
"CartContents": [
{
"lineID": 2000,
"prodDesc": "PLASTIC NUMBER \"0\" 75M With green border",
"productID": "16234",
"prodQty": 1,
"unitPrice": 0.0,
"usageCode": "",
"usageDesc": "",
"usageSequence": "",
"usageSection": 0
},
{
"lineID": 2001,
"prodDesc": "Glyn's LM Product #1 ",
"productID": "3243",
"prodQty": 1,
"unitPrice": 0.0,
"usageCode": "",
"usageDesc": "",
"usageSequence": "",
"usageSection": 0
}
]
}
]
}}

As you see there are must be two elements at 1x Bath, 1x Hardware, but actually it is one.
What did I miss?

Any help is much appreciated!

garkelly
19 Sep 2011, 2:50 AM
Any solution to this? Having the exact same problem

siebmanb
25 Sep 2011, 1:37 PM
I don't have the solution but I do have an advice if I may. It would be easier for you, and for helpers, if you simplified your code as much as possible. For example, simplifying your data structure with 1 or 2 properties only would make things easier to read...