PDA

View Full Version : using a Writer with a store



toddgeist
13 Jul 2010, 10:33 AM
hello,

I am not finding an easy way to add a Writer to a store that is defined in Ext Designer, without hand editing the Store file that is generated.

Is there a work-around?

Thanks

Todd

toddgeist
13 Jul 2010, 11:32 AM
But I am not sure it is a good idea.

I add a writer to the already instantiated store like so.


writer = new Ext.data.JsonWriter({
encode: true,
writeAllFields: false
});
MyStore.prototype.writer = writer

What do you think? Is this a good idea?

Thanks

Todd

toddgeist
13 Jul 2010, 12:53 PM
unfortunately this does not see to work:(

I really would love to get some feedback on how to do this

Todd

toddgeist
13 Jul 2010, 1:39 PM
OK this is my latest idea...


w = new Ext.data.JsonWriter({
encode: true,
writeAllFields: false
});

new PatientStore({writer:w}) ;

is this a good way to do it?

Thanks

Todd

jarrednicholls
14 Jul 2010, 6:24 AM
Hi Todd,

Yes the latest is the correct way to configure a writer to your Store. We will be adding pure writer configuration support in the Designer in a near future release. But what you have done is the correct way to supply a writer during construction of a Store. In general, you will find all Ext JS components & classes are configured by passing in a single configuration JSON object to the constructor, e.g.,


new Ext.Panel({
// Configurations go here
});

devtig
22 Oct 2010, 4:44 AM
Thanks. I need this too (now), because I'd like to keep as much components and stores in the Designer as possible when working on my project. But I'll work around for now.

devtig
22 Oct 2010, 4:55 AM
To dynamically add a writer to a store that is generated from Ext Designer I use this work around:


var store=Ext.StoreMgr.lookup('theStoreId');
store.writer=new Ext.data.JsonWriter({meta: store.reader.meta});

This way you don't have to temper with the js file for the store that is auto-generated by Ext Designer that wíll be overwritten next time you export from Ext Designer.

MHjerpe
4 Oct 2011, 7:37 AM
Trying to add a writer to a store in designer 1.2

as Devtig is doing.. All I get is this..

Uncaught TypeError: Cannot read property 'meta' of undefined


We are going to show of how easy it is to build gui's with the desginer.. and even an Row Edit..
The thing is that we must set the root property in the Json Writer so the backend can handle it the right way.

I see much talk in these forums that Json Writer is coming in a near future ? ( are we there yet ? )

joakim.dejong
10 Oct 2011, 12:53 AM
In Ext JS 4.0 to set the writer after the store has been created you can use "setWriter" on the proxy.
It seems that "meta" isn't used in 4.0.
Instead you should pass in the config object



var myProxy = Ext.StoreMgr.lookup('myStore').getProxy();
myProxy.setWriter(new Ext.data.JsonWriter({ root: 'myRoot', writeAllField: false }));