//>>built
define("mill/enhancedGridData",["dojo/DeferredList","dojox/grid/EnhancedGrid","mill/mill"],function(){dojo.declare("mill.enhancedGridData",null,{_id:null,_fetched:null,_handle:null,_parentItem:null,_callbacks:null,maxRecords:1E4,sync:!1,keyFieldName:"ID",labelFieldName:"Description",constructor:function(a){this._id=mill.enhancedGridData._lastID++;this._fetched=[];a&&dojo.mixin(this,a)},getValue:function(a,b,d){return a?a[b]||mill.fieldValue(a.node,b)||d:d},_hasChildren:function(a){return!1},_loaded:function(){return this._callbacks?
!this._callbacks.length&&!this._handle:!1},_nextPortion:function(a,b,d,e){if(e&&this._fetched.length>d)return this._parentItem=a,this._handle=e,this.fetch(b),this._callbacks.length&&this._callbacks.pop()(),!1;this._handle=this._parentItem=null;var c=e?this._handleParams(a,b,e):this._queryParams(a,b);dojo.mixin(c,{_nodes:[],_handle:[],sync:this.sync,load:dojo.hitch(this,function(f){if("error"==f.documentElement.nodeName){this._parentItem=this._handle=null;this._callbacks=[];f=b.scope?b.scope:dojo.global;
var g=Error(this.declaredClass+": error occured.");b.onError&&b.onError.call(f,g);return g}(g="1"==f.documentElement.getAttribute("eof")?null:f.documentElement.getAttribute("handle"))?c._handle.push(g):c._handle=[];g=f.documentElement.childNodes;for(var h=0;h!=g.length;h++)c._nodes.push(g.item(h));return f})});this._callbacks.unshift(dojo.hitch(this,this._loadNodes,c._nodes,a,b,d,c._handle));this._performQuery(c).addCallback(dojo.hitch(this,function(){for(;this._callbacks.length&&!this._callbacks.shift()(););
}));return!0},_loadNodes:function(a,b,d,e,c){for(var f=0;f<a.length;f++){var g={index:this._fetched.length,parentItem:b,store:this,node:a[f]};this.onItemCreated(g,d);this._fetched.push(g);if(this._hasChildren(g))return a=a.slice(f+1),this._nextPortion(g,d,e,null),a.length&&this._callbacks.unshift(this._callbacks.shift(),dojo.hitch(this,this._loadNodes,a,b,d,e,c)),!0}if(c.length)return this._nextPortion(b,d,e,c[0]),!0;this._eofReached(b,d);return!1},fetch:function(a){var b=a.scope?a.scope:dojo.global,
d=a.start||0,e=a.count&&Infinity!==a.count?d+a.count:this.maxRecords;0>d&&(e+=d,d=0);if(this._fetched.length<=e&&!this._loaded())this._callbacks=this._callbacks||[],this._callbacks.push(dojo.hitch(this,this.fetch,a)),this._nextPortion(this._parentItem,a,e,this._handle);else{a.onBegin&&a.onBegin.call(b,this._fetched.length+(this._loaded()?0:1),a);this.onBegin(this._fetched.length,a);for(var c=d;c<this._fetched.length&&c<e;c++)a.onItem&&a.onItem.call(b,this._fetched[c],a),this.onItem(this._fetched[c],
a);c=[];a.onItem||(c=this._fetched.slice(d,e));a.onComplete&&a.onComplete.call(b,c,a);this.onComplete(c,a)}return a},getIdentity:function(a){return this.getValue(a,this.keyFieldName)},getIdentityAttributes:function(a){return[this.keyFieldName]},getLabel:function(a){return this.getValue(a,this.labelFieldName)},getFeatures:function(){return{"dojo.data.api.Read":!0,"dojo.data.api.Identity":!0}},isItem:function(a){return a.store&&a.store._id==this._id},close:function(a){this._fetched=[];this._parentItem=
this._handle=null},onBegin:function(a,b){},onItem:function(a,b){},onComplete:function(a,b){},onItemCreated:function(a,b){},_handleParams:function(a,b,d){},_queryParams:function(a,b){},_performQuery:function(a){},_eofReached:function(a,b){}});dojo.mixin(mill.enhancedGridData,{_lastID:0})});