PDA

View Full Version : JsonStore Writer



cbox
30 Jun 2010, 2:46 AM
Hi,

Is there a way to define a writer for a datastore in the designer or where is the best place to add a writer to the datastore?

Best regards
Sylvester Nielsen

jarrednicholls
30 Jun 2010, 3:50 AM
You can add it in your exported store class (just make a copy of the file once your store is finished, so it's not overwritten):



MyStore1 = Ext.extend(Ext.data.JsonStore, {
constructor: function(cfg) {
cfg = cfg || {};
MyStore1.superclass.constructor.call(this, Ext.apply({
storeId: 'MyStore1',
url: 'json.php',
root: 'names',
fields: [
{
name: 'id'
},
{
name: 'name'
}
],
writer: new Ext.data.JsonWriter({...})
}, cfg));
}
});
new MyStore1();


Store improvements will be coming up in the near future, and allow you to swap readers and writers with a generic Ext.data.Store and configure them.

MartinL
13 Nov 2010, 12:01 AM
Are you sure there will be updates to the designer in the near future? Seems the team is more and more focused on sencha touch development?! It's not nice if you always have to copy code after the export again and again in the new exported code. If you are coding bigger and better solutions with ext js it gets very fast so complex you can n't remember where to copy code and it needs hours to debug the whole code again.