View Full Version : Problem with store.reader

5 Oct 2012, 8:41 AM
I'm trying to talk to a C# service - and in the json I get back - I need the inlinecount for the paging grid..
The problem - is that the inlinecount means data is send back in d.results - rather than in 'd'.
And - you cant use inlinecount for updates.
So - when I read from the store - I need reader.root = 'd.results'
when I write back - it need it to be 'd'

Using Maicon Schelter Odata connector - I'm trying to reset the 'reader.root' in the getParams function which is called to setup the URL for the service call - but its not taking my value..

Any ideas on how I should properly reset the "root" ?

5 Oct 2012, 9:22 AM
when I write back - it need it to be 'd'

Ext.data.writer.Json.root (http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.writer.Json-cfg-root)?

5 Oct 2012, 2:55 PM
I dont think thats it - the problem is after the data has been sent to the service successfully, and i'm getting the new data back (which includes the autoincrement/identity/serial column values etc)

5 Oct 2012, 5:14 PM
Writting back to server, proxy will use a writer while reading from server, it will use a reader. These two have their own root config. So you can configure them independently.

proxy: {
reader: {
type: 'json',
root: 'd.results'
writer: {
type: 'json',
root: 'd'

6 Oct 2012, 3:33 AM
No - as I said - the writer is correct - that seems to be used to *Send* the data to the service.
The problem is in the *response* to that service that comes back - which is used by the 'reader' again..

(I can see this using fiddler...)

Any other ideas ?

6 Oct 2012, 3:59 AM
So, if I understand correctly, your problem is that your server uses slightly different formats when responding to the two different types of request?

I think you're going to have to override something on the reader. I highly recommend looking over the code for Json reader (and its superclass), there's not much to it.

One option might be something like this:

Ext.define('CustomReader', {
alias: 'reader.custom-reader',
extend: 'Ext.data.reader.Json',

buildExtractors: function() {

// Remove the one created by buildExtractors, falling back to our version
delete this.getRoot;

getRoot: function(data) {
var d = data.d;

return d.results || d;


reader: {
type: 'custom-reader'