PDA

View Full Version : dynamic data in store and template



Robert82
27 Nov 2009, 6:47 AM
Hello,

I have a store and a template within a panel. My store get the data with metaData because my root can change to indicate what type of data is stored.

Could I define a template which iterate over my store and display the data independent of the changing root element? The fields are always the same.

My approach was the following:


tplMarkup: [
'<div class="x-tagCloud">',
' <ul>',
' <tpl for="keywords">', //this could change for different data
' <li ><a class="{weight:this.getFontSize}" id="{#}" href="#">{tag}</a></li>',
' </tpl>',
' </ul>',
'</div>'
],data:

{metaData: {"root":"keywords",
"fields": [{"name": "tag"},{"name": "weight"}]
},
"keywords":[{"tag":"CCCI metrics","weight":1},{"tag":"mashup","weight":4},{"tag":"quality","weight":1},{"tag":"reputation","weight":1},{"tag":"trust","weight":1},{"tag":"data","weight":1},{"tag":"information","weight":1},{"tag":"integration","weight":1},{"tag":"model","weight":1}]};and the store:

this.store = new Ext.data.JsonStore({
autoDestroy:true,
storeId: 'tagStore',
IdProperty:'tag',
root: 'tagList',
fields: [{name:'tag',type:'string'},{name:'weight',type:'int'}]
});//end of storeBut I have no idea for iterating over the store and than overwrite the template. Could you help me?