PDA

View Full Version : Json Data Store + Grouping Store



abirdd
31 Oct 2009, 1:04 PM
Simple question, I am using the JSON Data Store, since on the server side I can generate the metadata block automatically from the select statement, so 0 code required to add more columns to the datastore, then in takes almost no effort to add columns to the grid.

However, I really like the look and feel of the grouping datastore on a grid, it is far more effective then having just 5 different grids.

How can I combine a JSON Store with a Grouping Store? I tried using a JSON reader with the Grouping store, but it does not understand the METADATA block.

Any help would be appreciated.
Derek

lpastor
31 Oct 2009, 3:17 PM
You can use something like this for your store :


var proxy_contact = new Ext.data.HttpProxy({
url: 'Mysql_Call.php?table=contact&idkey=id_contact',
method: 'POST'
});

var reader_contact = new Ext.data.JsonReader({
totalProperty: 'total',
successProperty: 'success',
idProperty: 'id_contact',
root: 'data'
}, [
{name: 'id_contact'},
{name: 'nom_contact', sortDir: 'ASC', sortType: 'asUCString', allowBlank: false},
{name: 'email_contact'}
]);

var writer_contact = new Ext.data.JsonWriter();

var store_contact = new Ext.data.GroupingStore({
id: 'id_contact',
proxy: proxy_contact,
reader: reader_contact,
writer: writer_contact,
sortInfo:{field: 'nom_contact', direction: "ASC"},
listeners: {
write : function(store_contact, action, result, response, rs) {}
}
});

abirdd
31 Oct 2009, 5:52 PM
I will give it a try, I think I tried something similar to that earlier and got errors about my metadata .... Thank you very much
derek