PDA

View Full Version : [SOLVED] How to get extra data when loading Jsonstore for a grid ?



senacle
15 Jun 2010, 11:55 AM
Hi all !

I've a tbar with a menu.
When i click on a menu's element, i want to display a grid and some other data.




var store_grille_offre = new Ext.data.JsonStore({
autoDestroy: true,
url: 'some_url.php',
root: 'offre',
storeId: 'store_grille_offre',
idProperty: 'id_offre',
messageProperty: "titre",
fields: [
'id_offre',
...
]
});

handler: function() {
store_grille_offre.load({
method:'POST',
params:{contenu: 'nouveau'},
callback: function(r, options, success){
if (success) {
console.log(r);
panel_offre.render("grille_offre_2");
Ext.getCmp('info_panel_2').update( store_grille_offre.messageProperty);
} else {
}
}
});
}
The json data:


{
"success": true,
"offre": [
{
"id_offre": "477",
...
}
],
"titre": "some text here"
}No problem to display the grid and the data.

I don't know (and didn't find) how to display the data "titre". Instead of displaying some text here, it's titre wich is displayed.

Some idea and help ?

senacle
17 Jun 2010, 11:24 AM
I've found this : http://www.sencha.com/learn/Ext_FAQ_Grid#How_to_get_additional_data_sent_back_with_store_load.3F

So, in my code :



handler: function() {
store_grille_offre.load({
method:'POST',
params:{contenu: 'nouveau'},
callback: function(r, options, success){
if (success) {
var reader = this.reader;
var jsonData = reader.jsonData;
console.log(jsonData);
panel_offre.render("grille_offre_2");
Ext.getCmp('info_panel_2').update(jsonData.titre);
} else {
}
}
});
}