rest - EXTJS model idProperty field populated with model name? -
i trying create simple extjs5 app against restful rubyonrails backend. reason when instantiate model extjs populates "idproperty" field name of model (and counter). e.g.
{"traffic_id":"myapp.model.person-1","external_id":0,...
i thought "idproperty" field primary key of info record , set when record inserted in db (autoincrement)
so field should null or similar model has yet added store , syncd backend.
whats more amaising field defined 'int' , extjs puts string in it!
can tell me going on?
peter
below app.js fiddle with:
ext.application({ name : 'fiddle', launch : function() { var model = ext.create('myapp.model.person'); ext.msg.alert('fiddle', json.stringify(model.data)); } }); ext.define('myapp.model.person', { extend: 'ext.data.model', idproperty: 'traffic_id', proxy: { type: 'rest', // url: '/traffics.json', format: 'json', api: { create: 'traffics', read: 'traffics', update: 'traffics/edit', destroy: 'traffics' }, reader: { type: 'json', rootproperty: 'traffic', successproperty: 'success', messageproperty: 'message' }, writer: { type: 'json', //writeallfields : false, //encode: true, rootproperty: 'traffic' }, afterrequest: function(req, res) { console.log("ahoy!", req.operation.response); }, listeners: { exception: function(proxy, response, operation) { //debugger; ext.messagebox.show({ title: 'xxx remote exception', msg: operation.geterror(), icon: ext.messagebox.error, buttons: ext.msg.ok }); } } }, fields: [{ name: 'traffic_id', type: 'int' }, { name: 'external_id', type: 'int' }, { name: 'description', type: 'string' }, { name: 'insertuser', type: 'string' }, { name: 'insertdate', type: 'date' }] });
extjs assigns "provisional" id newly created models; can distinguish between models have been created client side have not yet been saved ("phantom" models) vs ones have been downloaded. such, knows when phone call create
vs update
, , (i think, memory) delete id when uploading create
rest endpoint.
it needs id newly-created model can go stores (e.g. session, if nil else).
the style of id see default sequential
generator.
see http://docs.sencha.com/extjs/5.0/apidocs/#!/api/ext.data.identifier.generator more.
rest extjs5
No comments:
Post a Comment