PDA

View Full Version : xtemplate jsonstore



jeroentimmers
24 Feb 2010, 1:47 AM
hello i want to use a jsaon store to fill a template with values.

the store is:



this.store = new Ext.data.JsonStore({
root: 'data',
totalProperty: 'count',
remoteSort: true,
proxy: new Ext.data.HttpProxy({url: '/php/performancemedia.php'}),
autoSave: false,
autoLoad: false,
fields:[
{name: 'id', type: 'int'},
{name: 'typeid', type: 'int'},
{name: 'type', type: 'string'},
{name: 'width', type: 'int'},
{name: 'height', type: 'int'},
{name: 'name', type: 'string'},
{name: 'active', type: 'bool'}
]
});

this.store.on('load', this.setMedia, this);
the result after a load is


{"count":"1","data":[{"id":"1","type":"Youtube","width":"425","height":"344","name":"Sjala","active":"1","typeid":"1"}]}
the xtemplate is as fllow


this.tt = new Ext.XTemplate(
'<p>Name: {name}</p>',
'<p>Width: {width}</p>',
'<p>Height: {height}</p>');
the listener setMedia is



setMedia: function(s, r, e)
{
var p = Ext.getCmp('mediacontent');
this.tt.overwrite(p.body, r[0]);
}
but when i run the complete code the mediacontent get an empty template with only Name Width Height, but no values...

What do i wrong....

jay@moduscreate.com
24 Feb 2010, 4:29 PM
why not just use a dataview?