java - how to stop master ajax request if slave ajax request fails in extjs -
i newbie extjs 4.1, developed small app wherein have master , slave concept i.e basis on master's ajax success have fire slave's ajax request, if slave fails master should fail , vice versa. please find below snipnet of code
controller.js
ext.define('basel3.controller.contacts', { extend: 'ext.app.controller', stores:['...my store goes here...'], models:['...my models goes here...'], views: ['...my views goes here...'], refs:[{ references goes here }], init: function(){ this.control({ .... }) }, save: function() { this.getrulesstore().save(); this.getruledetailsstore().save(); } }
as in aforementioned code can see have used stores save data in database, fires seperate ajax request, don't want do. below store , model of respective entities.
models
rule detail:
ext.define('basel3.model.ruledetail', { extend: 'ext.data.model', fields: [{name: 'ruledetailid', type: 'int'}, {name: 'ruleid',type: 'string'}, {name: 'attrname',type: 'string'}, {name: 'attrtype',type: 'string'}, {name: 'attroprtr',type: 'string'}, {name: 'attrvalue',type: 'string'} ] });
rule:
ext.define('basel3.model.rule', { extend: 'ext.data.model', fields: [{name: 'rulename',type: 'string'}, {name: 'rulegroup', type: 'string'}, {name: 'rulereportname', type: 'string'}, {name: 'rulecategory',type: 'string'}, {name: 'ruletypeid',type: 'string'}, {name: 'rulefactor',type: 'string'}, {name: 'effdate',type: 'date', dateformat :'d-m-y'} ] });
stores:
rule details:
ext.define('basel3.store.contacts', { extend: 'ext.data.store', model: 'basel3.model.contact', autoload: true, pagesize: 35, storeid : 'contacts', autoload: {start: 0, limit: 35}, sorters: ['attrtype'], groupfield: 'attrtype', proxy: { type: 'ajax', api: { read : 'ruledetail/view.action', create : 'ruledetail/create.action', update: 'ruledetail/update.action', destroy: '' }, model : 'basel3.model.contact', reader: { //reads data in json format type: 'json', root: 'data', successproperty: 'success' }, writer: { type: 'json', //writes data in json format writeallfields: true, encode: true, root: 'data' }, listeners: { //exception handler ajax request exception: function(proxy, response, operation){ var error = ext.decode(response.responsetext); ext.messagebox.show({ title: 'rule details remote exception', msg: error.message, icon: ext.messagebox.error, buttons: ext.msg.ok }); } } } });
rules:
ext.define('intellectb3.store.rule', { extend: 'ext.data.store', model: 'intellectb3.model.rule', storeid : 'rule', autoload: true, pagesize: 35, autosync : true, autoload: {start: 0, limit: 35}, proxy: { type: 'ajax', api: { read : 'rule/view.action', create : 'rule/create.action', update: 'rule/update.action', destroy: '' }, reader: { type: 'json', root: 'data', successproperty: 'success' }, writer: { type: 'json', //writes data in json format writeallfields: true, encode: true, root: 'data' }, listeners: { //exception handler ajax request exception: function(proxy, response, operation){ var error = ext.decode(response.responsetext); ext.messagebox.show({ title: 'rule master remote exception', msg: error.message, icon: ext.messagebox.error, buttons: ext.msg.ok }); } } } });
thanks in advance, waiting humble replies
Comments
Post a Comment