javascript - How to add record to ExtJS store "persistently"? -


there 2 stores same model : inputstore , outputstore. grid in concepts panel display data inputstore. when user checkboxes row in grid (via ext.selection.checkbox.model), record added in outputstore.

i've managed cannot add record persistently outputstore. here how did :

i added listener ext.selection.checkbox.model part of grid:

selmodel: ext.create('ext.selection.checkboxmodel', { listeners: {     select: {         fn: me.oncheckboxmodelselect,         scope: me     } } }) 

and record added outputstore works fine.

oncheckboxmodelselect: function(rowmodel, record, index, eopts) {     var griddd = ext.componentquery.query('#outputgridpanel')[0];     griddd.getstore().add(record); } 

i've tried store.sync(), store.commitchanges() , store.save().

hi back! changed both stores inline data stores json stores proxy. example here outputstore:

ext.define('justconcepts.store.outputstore', { extend: 'ext.data.store',  requires: [     'justconcepts.model.conceptsmodel',     'ext.data.proxy.ajax',     'ext.data.reader.json' ],  constructor: function(cfg) {     var me = this;     cfg = cfg || {};     me.callparent([ext.apply({         autoload: true,         autosync: true,         model: 'justconcepts.model.conceptsmodel',         storeid: 'outputstore',         proxy: {             type: 'ajax',             url: 'data/output.json',             reader: {                 type: 'json',                 root: 'concepts'             }         }     }, cfg)]); } }); 

here data/output.json file :

{ concepts: [     {         "id": "00a212",         "name": "pays",         "adjacencies": ["00a213", "01a455"]       },     {         "id": "00a213",         "name": "ville",         "adjacencies": ["00a212"]       },       {         "id": "01a455",         "name": "fleuve",        "adjacencies": ["00a212"]       }  ] } 

griddd.getstore().add(record); still working cannot persist , griddd.getstore().getproxy().getmodel().save(); not working.

your problem in model definition.

have tried:

griddd.getstore().getproxy().getmodel().save(); 

and way method ext.data.store.save() not exist. mean, think removed versions v4.x of extjs.

example taken sencha extjs docs

//this model using in store ext.define('user', {     extend: 'ext.data.model',     fields: [         {name: 'id',    type: 'int'},         {name: 'name',  type: 'string'},         {name: 'phone', type: 'string', mapping: 'phonenumber'}     ] });  //this data not line our model fields - phone field called phonenumber var data = {     users: [         {             id: 1,             name: 'ed spencer',             phonenumber: '555 1234'         },         {             id: 2,             name: 'abe elias',             phonenumber: '666 1234'         }     ] };  //note how set 'root' in reader match data structure above var store = ext.create('ext.data.store', {     autoload: true,     model: 'user',     data : data,     proxy: {         type: 'memory',         reader: {             type: 'json',             root: 'users'         }     } }); 

you have information in there. if need specific help, should post code can you!


Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -