View Full Version : REST Store autosyncing empty inserted row

13 Nov 2013, 10:54 AM
I have a REST data store backing a grid panel and everything (even edits) is working. Problem is I need a way to add a row. I have seen code like (below) this, but what is happening is when I insert the record into the store it is hitting the REST service adding an empty record. Plus the new row in the grid doesn't have the "id" of the inserted record. How is this properly handled with a REST data source?

var rec = new Card({
id: 0,
name: ' ',
address: ' ',
rate: 0,
date_added: new Date(),
available_date: new Date(),
picture: ' '
store.insert(0, rec);

Let me try to answer my own question. You just toggle autosync before and after insert, correct?

13 Nov 2013, 11:14 AM
I had the same problem of not getting the id back, but after I specified an explicit reader/writer in the store, and explicitly setting the id property it worked:

proxy: {
type: 'rest',
url: '/accounts',
writer: {
type: 'json'
reader: {
type: 'json',
idProperty: '_id',
messageProperty: 'message',
root: 'data'

18 Nov 2013, 1:16 PM
Not my problem. I found you must disable autosync.