View Full Version : DirectStore not writable? Doesn't work with Direct Providers?

3 Jun 2009, 5:37 PM
Shouldn't the creation of a directStore also create a writer based on the passed api? I figured if I passed in an api with a create and update that a directStore would know what to do with them...

4 Jun 2009, 8:19 AM
OK, now I have added my own writer. So closer, but now it doesn't have enough parameters when creating. My API actions are defined as follows:

{ "name":"update", "len":2 } ,
{ "name":"create", "len":1 } ,
{ "name":"destroy", "len":1 } ,
{ "name":"read", "len":0 }

and the store:

store = new Ext.data.DirectStore({
autoSave: false,
reader: reader,
api: api,
paramsAsHash: false, // without this it won't actually read, nor return an error about it
writer: writer

The first thing you'll notice is that I have paramsAsHash set to false. I have to do this because of a bug that the read call expects no parameters, but with paramsAsHash set to true it adds one anyway, and then the callback is in the wrong place and it never gets called, thus the store doesn't know that the ajax request is ever finished.

Anyhow, even changing that back to true doesn't work.

I thought that a DirectStore would just consume a DirectProvider api and be done with it. What am I missing? How can I get this to work?

4 Jun 2009, 3:10 PM
The first issue is easily remedied by having the DirectStore create a writer if using an api instead of a directFn. The second issue is fixed by setting root to '' when root is undefined. The issue with wrong param count for api.read is fixed by defaulting paramsAsHash to false, not true.

22 Jun 2009, 4:49 PM
Fourth issue: you can't write/create on a store that hasn't been loaded yet since realize calls extractValues without checking first to see if buildExtractors was called, resulting in calls to this.ef[j](data) where this.ef is not defined.

22 Jun 2009, 7:32 PM
#4 - Try SVN.