PDA

View Full Version : New record will pass to server through 'update' api not the 'create' api.



panbayi
28 Sep 2013, 12:27 AM
I hava a model named 'person' with fields : ['id','name','phone','email'],and the 'id' field map primary key of my 'person' table in database.Then I define a store named 'person' with the model 'person'.When I add a new record to the 'person' store and edit it .Then I call store.sync() to save the record to server.Here is the problem : the new record will not request through 'create' api but the 'update' api. I guess the cause of this situation is that when the 'id' field(which is the default value of idProperty of 'Ext.data.Model') has a not null value then ExtJS treate it as a existing record in the server rather than a new record created on the client side. Is my guess correct?How to solve this problem?If I set idProperty:null ,will it work? Any help is appreciated!

Farish
28 Sep 2013, 1:12 AM
the id should be 0 for new records. also, the phantom flag is set to true on new records. this is done automatically if you create a new record without assigning an id value to it.