i have defined my model with a REST proxy. it works fine for read (GET) and update (PUT) because those operations require a primary id. when i perform a create operation (POST) the proxy sends all the fields, including the empty primary id, to the server, which causes and error on the server. the server expects that no primary id is to be included for a create operation. how do i instruct extjs to not send the empty primary id value? ie. “{ ‘model_id’:”,…}”?
Ext.define('model', {
extend : 'Ext.data.Model',
idProperty : 'model_id',
fields : ['model_id', 'first', 'last'],
proxy : {
type : 'rest'
}
});
var mymodel = Ext.create('model',{last:'digler'});
mymodel.save() //posts "{ 'model_id':'', 'last':'digler'}"?
i want it to not include the primary id field at all on a create.
I think that this is a wrong way to change the structure of request. In the case of usage REST, the responsibility to operate create, update requests are fully on server side.
In the case you still want to change parameters when create request is started, you can do it by “beforerequest” event:
Just for example I re-defines data fields hard coded, but, of course, it’s possible to run through all fields in loop without writting its names in code.