Brendan
1 May 2011, 10:10 PM
Hi all,
I've been trying to load a multilayered json feed:
{ "markets": [ {
"marketname":"A",
"selections": [
{"name":"B"},
{"name":"C"},
},
{
"marketname":"D",
"selections": [
{"name":"E"},
{"name":"F"}
}
]}
from my understanding I can load this with somthing like:
Ext.regModel('Markets', {
fields: ['marketname'],
hasMany: {model: 'Selections', name: 'selections'}
});
Ext.regModel('Selections', {
fields: ['name'],
belongsTo: 'Markets'
});
var store = new Ext.data.JsonStore({
model : 'Markets',
sorters: 'marketname',
getGroupString : function(record) {
return record.get('marketname');
},
proxy: {
type: 'ajax',
url : 'json.php',
reader: {
type: 'json',
root: 'markets'
}
}
var list = new Ext.List({
itemTpl : '{marketname}',
grouped : true,
indexBar: false,
xtype: 'list',
store: store
So, you can see from the above code I'm basically making a list, but what I want to do is show the data so that it is grouped by the marketnames
somthing like:
A
-> B
-> C
D
-> E
-> F
I'm basically totally in over my head, and from teh doco I have read it seems that the json it to complex for a simple store?
If anyone can give me some pointers in getting the json above into a list that is groupable and sortable that would be great, the preference would be to get the regModel looking like:
Ext.regModel('Markets', {
fields: ['marketname','name'],
});
so there would be:
A,B
A,C
D,E
D,F
This I can sort much easier on the first field etc.
thanks.
I've been trying to load a multilayered json feed:
{ "markets": [ {
"marketname":"A",
"selections": [
{"name":"B"},
{"name":"C"},
},
{
"marketname":"D",
"selections": [
{"name":"E"},
{"name":"F"}
}
]}
from my understanding I can load this with somthing like:
Ext.regModel('Markets', {
fields: ['marketname'],
hasMany: {model: 'Selections', name: 'selections'}
});
Ext.regModel('Selections', {
fields: ['name'],
belongsTo: 'Markets'
});
var store = new Ext.data.JsonStore({
model : 'Markets',
sorters: 'marketname',
getGroupString : function(record) {
return record.get('marketname');
},
proxy: {
type: 'ajax',
url : 'json.php',
reader: {
type: 'json',
root: 'markets'
}
}
var list = new Ext.List({
itemTpl : '{marketname}',
grouped : true,
indexBar: false,
xtype: 'list',
store: store
So, you can see from the above code I'm basically making a list, but what I want to do is show the data so that it is grouped by the marketnames
somthing like:
A
-> B
-> C
D
-> E
-> F
I'm basically totally in over my head, and from teh doco I have read it seems that the json it to complex for a simple store?
If anyone can give me some pointers in getting the json above into a list that is groupable and sortable that would be great, the preference would be to get the regModel looking like:
Ext.regModel('Markets', {
fields: ['marketname','name'],
});
so there would be:
A,B
A,C
D,E
D,F
This I can sort much easier on the first field etc.
thanks.