PDA

View Full Version : This is possible with a jsonstore and a Dataview?



willy99
11 Feb 2010, 1:19 AM
Hello I need your help.

I can not find the way to build a correct jsonstore config to do this:

This is the template:

var tpl = new Ext.XTemplate(
'<p>{total}</p>',
'<tpl for="carpetas">',
' <div class="x-carpeta">',
' <!-- CARPETAS -->
' </div>',
'</tpl>',
'<tpl for="archivos">',
' <div class="x-archivos">',
' <!-- ARCHIVOS -->
' </div>',
'</tpl>',
'<div class="x-clear"></div>'
);



The Dataview:

var dv=new Ext.DataView({
id:"DVexplorer",
store: store,
tpl: tpl,
multiSelect: true
})


And the jsonstore incomplete:


var store= new Ext.data.JsonStore({
autoDestroy:true,
url: 'server.php?AJAX=EXPLORE',
baseParams: {
'path': path
},
root: ?????
fields: [?????]
});


This is the data that I want to process with the jsonstore.

{
total: 5,
carpetas: [
{
nom: 'Folder1',
size: 3
},
{
nom: 'Folder2',
size: 1
},
{
nom: 'Folder3',
size: 2
}
],
archivos: [
{
nom: 'File1',
size: 25600
},
{
nom: 'File2',
size: 128
}
]
}


This template and dataview works fine setting the dataview data property with this data, and not configuring the dataview store property.

I can not find how to configure the two arrays in the jsonstore (two roots?).
I'm lost and need your help.
thanks.