How to save data from editable grid in ExtJS in a json file and refresh grid with changes? -
i have editable grid in extjs. fetch data json file , trying save after editing. after editing, click on save , call store.sync() makes no change in json file , grid refreshed state prior editing. newbie extjs. missing here, how make work?
ext.define('user', { extend: 'ext.data.model', fields: [ {name: 'pricelist', type: 'string'}, {name: 'productfamily', type:'string'}, {name: 'producttype', type:'string'}, {name: 'productsubgroup', type: 'string'}, {name: 'item', type: 'string'}, {name: 'level', type: 'string'}, {name: 'factor', type:'string'}, {name: 'factorvalue', type: 'string'}, {name: 'effstrtdate', type: 'string'}, {name: 'effenddate', type: 'string'}, {name: 'comments', type: 'string'} ] }); var userstore = ext.create('ext.data.jsonstore', { model: 'user', proxy: { type: 'ajax', url: '/pwbench/form/products/fctrmgmt/data.json', api: { read: '/pwbench/form/products/fctrmgmt/data.json', update: '/pwbench/form/products/fctrmgmt/data.json' }, reader: { type: 'json', } }, autoload: true }); var grid = ext.create('ext.grid.panel', { renderto: ext.getbody(), store: userstore, title: 'application users', seltype: 'cellmodel', plugins: [ ext.create('ext.grid.plugin.cellediting', { clickstoedit: 1 }) ], columns: [.... ], tbar: [ { text: 'save', handler: function() { userstore.sync(); userstore.load(); } } ], }); ext.application({ requires: ['ext.container.viewport'], name: 'extgrid', launch: function() { ext.create('ext.container.viewport', { items: grid, width: 800, height: 600 }); } });
you can't "update json" without other interaction. imagine how big of security flaw be, http request update file on server.
you need server side technology, php/java/.net/other take response , write file. there plenty of examples of in ext sdk download.
Comments
Post a Comment