tags:

views:

606

answers:

2

I'm receiving a "Ext.data.DataReader: #realize was called with invalid remote-data" error when I create a new record via a POST request. Although similar to the discussion at this SO conversation, my situation is slightly different:

My server returns the pk of the new record and additional information that is to be associated with the new record in the grid. My server returns the following:

{'success':true,'message':'Created Quote','data': [{'id':'610'}, {'quoteNumber':'1'}]}

Where id is the PK for the record in the mysql database. quoteNumber is a db generated value that needs to be added to the created record.

Other relevant bits:

var quoteRecord = Ext.data.Record.create([{name:'id', type:'int'},{name:'quoteNumber', type:'int'},{name:'slideID'}, {name:'speaker'},{name:'quote'}, {name:'metadataID'}, {name:'priorityID'}]);

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

var quoteReader = new Ext.data.JsonReader({id:'id', root:'data',totalProperty: 'totalitems', successProperty: 'success',messageProperty: 'message',idProperty:'id'}, quoteRecord);

I'm stumped. Anyone??

thanks

tom

+1  A: 

Turns out that the response from the server should look like this:

{'success':true,'message':'Created Quote','data': [{'id':'610','quoteNumber':'1'}]}

A subtle difference, not one that I'm certain I understand.

TomH
+2  A: 

[Responding with an answer instead of a comment for code formatting...]

Some indented formatting will make the difference clear. This (correct) form returns a single object with two properties:

{
    'success':true,
    'message':'Created Quote',
    'data': [{
        'id':'610',
        'quoteNumber':'1'
    }]
}

Your original format returned two separate objects with mismatched properties that cannot be resolved into columns:

{
    'success':true,
    'message':'Created Quote',
    'data': [{
        'id':'610'
    },{
        'quoteNumber':'1'
    }]
}
bmoeskau