PDA

View Full Version : No more data available in JsonStore when using MetaData property



tiefschnee
2 Feb 2010, 6:00 AM
Hi there!

I'm using the organizer example for displaying an image gallery view. Everything works fine so far but when I add a MetaData field (as described in the api docs) to the server's Json response which passes some custom properties to my Store object the store's data items and keys fields remain empty. The firebug console also shows that those data fields are empty whereas reader > JsonData holds an element metaData with the proper fields and data returned by my server.

How can I access my metaData? Shouldn't it be available in the store's regular data object?

The Json data returned by the server (I truncated the "result" data) :

{
"metaData":{
"root":"results",
"idProperty":"name",
"totalProperty":"total",
"sortInfo":{
"field":"name",
"direction":"ASC"
},
"fields":[
{"name":"name","type":"string"},
{"name":"url","type":"string"},
{"name":"thumb_width","type":"string"},
{"name":"thumb_height","type":"string"},
{"name":"shortName","mapping":"name","convert":"shortName"}
]
},
"total":"150",
"results":[
{"name":"Fliegenpilz.JPG","url":"\/users\/1001\/images\/thumbs\/1001_16872_100.jpg","thumb_width":80,"thumb_height":60},
{"name":"Freestyle_1.jpg","url":"\/users\/1001\/images\/thumbs\/1001_16773_100.jpg","thumb_width":80,"thumb_height":54},
{"name":"Unbenannt.png","url":"\/users\/1001\/images\/thumbs\/1001_16568_100.jpg","thumb_width":80,"thumb_height":25},
{"name":"hoff_2.jpg","url":"\/users\/1001\/images\/thumbs\/1001_16490_100.jpg","thumb_width":53,"thumb_height":80},
{...}
]
}


The ExtJs part:

// Set up images view

var view = new Ext.DataView({
itemSelector: 'div.thumb-wrap',
style:'overflow:auto',
multiSelect: true,
plugins: new Ext.DataView.DragSelector({dragSafe:true}),
store: new Ext.data.JsonStore({
url: '/xbm/builds/0912/data/data.MyImages.php',
autoLoad: false
}),
tpl: new Ext.XTemplate(
'<tpl for=".">',
'<div class="thumb-wrap" id="{name}">',
'<div class="thumb"><table cellspacing="0" cellpadding="0" border="0"><tr><td height="80" width="80" align="center" valign="middle"><img src="{url}" class="thumb-img" width="{thumb_width}" height="{thumb_height}" title="{name}" /></td></tr></table></div>',
'<span>{shortName}</span></div>',
'</tpl>'
)
});

view.store.load({params:{start: 0, limit: 15}});

console.info(view.store);

When I return the server Json response without the metaData the data is displayed, with the metaData it's not.

Any idea what I'm doing wrong here???

Thanks in advance for your help