//>>built
define("dojox/grid/enhanced/plugins/Exporter","dojo/_base/declare dojo/_base/array dojo/_base/lang ../_Plugin ../../_RowSelector ../../EnhancedGrid ../../cells/_base".split(" "),function(q,n,e,r,t,u){var v=e.getObject("dojox.grid.cells"),h=q("dojox.grid.enhanced.plugins.Exporter",r,{name:"exporter",constructor:function(a,b){this.grid=a;this.formatter=b&&e.isObject(b)&&b.exportFormatter;this._mixinGrid()},_mixinGrid:function(){var a=this.grid;a.exportTo=e.hitch(this,this.exportTo);a.exportGrid=e.hitch(this,
this.exportGrid);a.exportSelected=e.hitch(this,this.exportSelected);a.setExportFormatter=e.hitch(this,this.setExportFormatter)},setExportFormatter:function(a){this.formatter=a},exportGrid:function(a,b,d){e.isFunction(b)&&(d=b,b={});if(e.isString(a)&&e.isFunction(d)){b=b||{};var c=this.grid,f=this,g=this._getExportWriter(a,b.writerArgs);b=b.fetchArgs&&e.isObject(b.fetchArgs)?b.fetchArgs:{};var k=b.onComplete;if(c.store)b.onComplete=function(p,w){k&&k(p,w);d(f._goThroughGridData(p,g))},b.sort=b.sort||
c.getSortProps(),c._storeLayerFetch(b);else{a=b.start||0;b=b.count||-1;for(var l=[],m=a;m!=a+b&&m<c.rowCount;++m)l.push(c.getItem(m));d(this._goThroughGridData(l,g))}}},exportSelected:function(a,b,d){if(!e.isString(a))return"";a=this._getExportWriter(a,b);return d(this._goThroughGridData(this.grid.selection.getSelected(),a))},_buildRow:function(a,b){var d=this;n.forEach(a._views,function(c,f){a.view=c;a.viewIdx=f;b.beforeView(a)&&(n.forEach(c.structure.cells,function(g,k){a.subrow=g;a.subrowIdx=k;
b.beforeSubrow(a)&&(n.forEach(g,function(l,m){a.isHeader&&d._isSpecialCol(l)&&a.spCols.push(l.index);a.cell=l;a.cellIdx=m;b.handleCell(a)}),b.afterSubrow(a))}),b.afterView(a))})},_goThroughGridData:function(a,b){var d=this.grid,c=n.filter(d.views.views,function(g){return!(g instanceof t)}),f={grid:d,isHeader:!0,spCols:[],_views:c,colOffset:c.length<d.views.views.length?-1:0};b.beforeHeader(d)&&(this._buildRow(f,b),b.afterHeader());f.isHeader=!1;b.beforeContent(a)&&(n.forEach(a,function(g,k){f.row=
g;f.rowIdx=k;b.beforeContentRow(f)&&(this._buildRow(f,b),b.afterContentRow(f))},this),b.afterContent());return b.toString()},_isSpecialCol:function(a){return a.isRowSelector||a instanceof v.RowIndex},_getExportWriter:function(a,b){var d;var c=h;if(c.writerNames){c=c.writerNames[a.toLowerCase()];if(d=e.getObject(c))return c=new d(b),c.formatter=this.formatter,c;throw Error('Please make sure class "'+c+'" is required.');}throw Error('The writer for "'+a+'" has not been registered.');}});h.registerWriter=
function(a,b){h.writerNames=h.writerNames||{};h.writerNames[a]=b};u.registerPlugin(h);return h});