PDA

View Full Version : DataView XTemplate multi dimensional Json string



JackCo
12 Nov 2010, 3:59 AM
Data:


{"success":true,"data":{"setting":0,"items":[
{"id":1,"link":"link1","icon":"icon1.jpg","title":"tile1"},
{"id":2,"link":"link2","icon":"icon2.jpg","title":"tile2"}
// etc etc
]}}
Store:


buildStore: function() {
return {
xtype: 'jsonstore',
url: this.url,
root: 'data.items',
fields: ['id', 'link', 'title', 'icon', 'active'],
successProperty: 'success'
};
},
XTemplate:


buildXTemplate: function() {
var tpl = new Ext.XTemplate(
'<tpl for=".">',
'<div>',
'<img src="/images/{icon}" title="{title}">',
'</div>',
'</tpl>',
'<div class="x-clear"></div>'
);
return tpl;
}
What i want todo is put text in my template based on two things: number of records = 0 and the value of setting in my jsonstring. Something like this:


...
'<tpl if="setting == 1">',
'{[xcount > 0 ? "scenario 1A" : "scenario 1B"]}',
'</tpl>'
...
'<tpl if="setting == 2">',
'{[xcount > 0 ? "scenario 2A" : "scenario 2B"]}',
'</tpl>'
The jsonstore root data.items prevents me from using setting, but when i use root data i cannot use my fields. I looked at a lot of examples, but it cannot put the pieces together to make it work.

--

Jack

JackCo
15 Nov 2010, 12:14 PM
bump

darthwes
15 Nov 2010, 12:53 PM
Are you saying your issue is that you cannot simultaneously use your template and the store together because of your meta field's presence in the json? Or are you having a problem with the template you're using?