//>>built
define("dgrid/_StoreMixin",["dojo/_base/kernel","dojo/_base/declare","dojo/_base/lang","dojo/_base/Deferred","dojo/on","put-selector/put"],function(_1,_2,_3,_4,_5,_6){function _7(_8){if(typeof _8!=="object"){_8=new Error(_8);}_8.grid=this;if(_5.emit(this.domNode,"dgrid-error",{grid:this,error:_8,cancelable:true,bubbles:true})){console.error(_8);}};return _2("dgrid._StoreMixin",null,{store:null,query:null,queryOptions:null,getBeforePut:true,noDataMessage:"",loadingMessage:"",constructor:function(){this.query={};this.queryOptions={};this.dirty={};this._updating={};},_configColumn:function(_9){if(_9.set){if(!this._columnsWithSet){this._columnsWithSet={};}this._columnsWithSet[_9.field]=_9;}},_configColumns:function(){this._columnsWithSet=null;return this.inherited(arguments);},_setStore:function(_a,_b,_c){this.store=_a;this.dirty={};this.set("query",_b,_c);},_setQuery:function(_d,_e){var _f=_e&&_e.sort;this.query=_d!==undefined?_d:this.query;this.queryOptions=_e||this.queryOptions;_f?this.set("sort",_f):this.refresh();},setStore:function(_10,_11,_12){_1.deprecated("setStore(...)","use set(\"store\", ...) instead","dgrid 1.0");this.set("store",_10,_11,_12);},setQuery:function(_13,_14){_1.deprecated("setQuery(...)","use set(\"query\", ...) instead","dgrid 1.0");this.set("query",_13,_14);},_getQueryOptions:function(){var _15=_3.delegate(this.queryOptions,{});if(this._sort.length){_15.sort=this._sort;}return _15;},_getQuery:function(){var q=this.query;return typeof q=="object"&&q!=null?_3.delegate(q,{}):q;},_setSort:function(_16,_17){if(this.store){this._lastCollection=null;}this.inherited(arguments);},insertRow:function(_18,_19,_1a,i,_1b){var _1c=this.store,_1d=this.dirty,id=_1c&&_1c.getIdentity(_18),_1e;if(id in _1d&&!(id in this._updating)){_1e=_1d[id];}if(_1e){_18=_3.delegate(_18,_1e);}return this.inherited(arguments);},updateDirty:function(id,_1f,_20){var _21=this.dirty,_22=_21[id];if(!_22){_22=_21[id]={};}_22[_1f]=_20;},setDirty:function(id,_23,_24){_1.deprecated("setDirty(...)","use updateDirty() instead","dgrid 1.0");this.updateDirty(id,_23,_24);},save:function(){var _25=this,_26=this.store,_27=this.dirty,dfd=new _4(),_28=dfd.promise,_29=function(id){var _2a;return (_25.getBeforePut||!(_2a=_25.row(id).data))?function(){return _26.get(id);}:function(){return _2a;};};function _2b(id,_2c){return function(_2d){var _2e=_25._columnsWithSet,_2f=_25._updating,key,_30;for(key in _2c){_2d[key]=_2c[key];}if(_2e){for(key in _2e){_30=_2e[key].set(_2d);if(_30!==undefined){_2d[key]=_30;}}}_2f[id]=true;return _4.when(_26.put(_2d),function(){delete _27[id];delete _2f[id];});};};for(var id in _27){var put=_2b(id,_27[id]);_28=_28.then(_29(id)).then(put);}dfd.resolve();return _28;},revert:function(){this.dirty={};this.refresh();},_trackError:function(_31){var _32;if(typeof _31=="string"){_31=_3.hitch(this,_31);}try{_32=_31();}catch(err){_7.call(this,err);}return _4.when(_32,null,_3.hitch(this,_7));},newRow:function(){if(this.noDataNode){_6(this.noDataNode,"!");delete this.noDataNode;}return this.inherited(arguments);},removeRow:function(_33,_34){var row={element:_33};if(!_34&&this.noDataMessage&&(this.up(row).element===_33)&&(this.down(row).element===_33)){this.noDataNode=_6(this.contentNode,"div.dgrid-no-data");this.noDataNode.innerHTML=this.noDataMessage;}return this.inherited(arguments);}});});