text: (function(d){"function"===typeof define&&define.amd?define(["jquery","./grid.base"],d):"object"===typeof exports?d(require("jquery")):d(jQuery)})(function(d){var C=d.jgrid,x=d.fn.jqGrid;C.extend({groupingSetup:function(){return this.each(function(){var b,m;m=this.p;var f=m.colModel,a=m.groupingView,c,k,e=function(){return""};if(null===a||"object"!==typeof a&&!d.isFunction(a))m.grouping=!1;else if(a.groupField.length){void 0===a.visibiltyOnNextGrouping&&(a.visibiltyOnNextGrouping=[]);a.lastvalues=
  [];a._locgr||(a.groups=[]);a.counters=[];for(b=0;b<a.groupField.length;b++)a.groupOrder[b]||(a.groupOrder[b]="asc"),a.groupText[b]||(a.groupText[b]="{0}"),"boolean"!==typeof a.groupColumnShow[b]&&(a.groupColumnShow[b]=!0),"boolean"!==typeof a.groupSummary[b]&&(a.groupSummary[b]=!1),a.groupSummaryPos[b]||(a.groupSummaryPos[b]="footer"),c=f[m.iColByName[a.groupField[b]]],!0===a.groupColumnShow[b]?(a.visibiltyOnNextGrouping[b]=!0,null!=c&&!0===c.hidden&&x.showCol.call(d(this),a.groupField[b])):(a.visibiltyOnNextGrouping[b]=
  d("#"+C.jqID(m.id+"_"+a.groupField[b])).is(":visible"),null!=c&&!0!==c.hidden&&x.hideCol.call(d(this),a.groupField[b]));a.summary=[];a.hideFirstGroupCol&&(a.formatDisplayField[0]=function(a){return a});b=0;for(m=f.length;b<m;b++)c=f[b],a.hideFirstGroupCol&&!c.hidden&&a.groupField[0]===c.name&&(c.formatter=e),c.summaryType&&(k={nm:c.name,st:c.summaryType,v:"",sr:c.summaryRound,srt:c.summaryRoundType||"round"},c.summaryDivider&&(k.sd=c.summaryDivider,k.vd=""),a.summary.push(k))}else m.grouping=!1})},
  groupingPrepare:function(b,m){this.each(function(){var f=this.p.groupingView,a=f.groups,c=f.counters,k=f.lastvalues,e=f.isInTheSameGroup,n=f.groupField.length,q,u,g,v,h=!1,w=x.groupingCalculations.handler;for(q=0;q<n;q++)if(u=f.groupField[q],g=f.displayField[q],v=b[u],g=null==g?null:b[g],null==g&&(g=v),void 0!==v){u={idx:q,dataIndex:u,value:v,displayValue:g,startRow:m,cnt:1,summary:[]};0===m?(a.push(u),k[q]=v,g={cnt:1,pos:a.length-1,summary:d.extend(!0,[],f.summary)},c[q]=g):(g={cnt:1,pos:a.length,
  summary:d.extend(!0,[],f.summary)},"object"===typeof v||(d.isArray(e)&&d.isFunction(e[q])?e[q].call(this,k[q],v,q,f):k[q]===v)?h?(a.push(u),k[q]=v,c[q]=g):(g=c[q],g.cnt+=1,a[g.pos].cnt=g.cnt):(a.push(u),k[q]=v,h=!0,c[q]=g));v=a[g.pos];for(var B=void 0,r=void 0,y=void 0,B=0;B<g.summary.length;B++)r=g.summary[B],y=d.isArray(r.st)?r.st[u.idx]:r.st,d.isFunction(y)?r.v=y.call(this,r.v,r.nm,b,u):(r.v=w.call(d(this),y,r.v,r.nm,r.sr,r.srt,b),"avg"===y.toLowerCase()&&r.sd&&(r.vd=w.call(d(this),y,r.vd,r.sd,
  r.sr,r.srt,b)));v.summary=g.summary}});return this},groupingToggle:function(b,m){this.each(function(){var f=this.p,a=f.groupingView,c=a.minusicon,k=a.plusicon,e=m?d(m).closest("tr.jqgroup"):d("#"+C.jqID(b)),n,q,u=!0,g=!1,v=[],h=function(a){var b,c=a.length;for(b=0;b<c;b++)v.push(a[b])},w=parseInt(e.data("jqgrouplevel"),10);f.frozenColumns&&0<e.length&&(q=e[0].rowIndex,e=d(this.rows[q]),e=e.add(this.grid.fbRows[q]));n=e.find(">td>span.tree-wrap");C.hasAllClasses(n,c)?(n.removeClass(c).addClass(k),
  g=!0):n.removeClass(k).addClass(c);for(e=e.next();e.length;e=e.next())if(e.hasClass("jqfoot"))if(n=parseInt(e.data("jqfootlevel"),10),g){if(n=parseInt(e.data("jqfootlevel"),10),(!a.showSummaryOnHide&&n===w||n>w)&&h(e),n<w)break}else{if((n===w||a.showSummaryOnHide&&n===w+1)&&h(e),n<=w)break}else if(e.hasClass("jqgroup"))if(n=parseInt(e.data("jqgrouplevel"),10),g){if(n<=w)break;h(e)}else{if(n<=w)break;n===w+1&&(e.find(">td>span.tree-wrap").removeClass(c).addClass(k),h(e));u=!1}else(g||u)&&h(e);d(v).css("display",
  g?"none":"");f.frozenColumns&&d(this).triggerHandler("jqGridResetFrozenHeights",[{header:{resizeDiv:!1,resizedRows:{iRowStart:-1,iRowEnd:-1}},resizeFooter:!1,body:{resizeDiv:!0,resizedRows:{iRowStart:q,iRowEnd:e.length?e[0].rowIndex-1:-1}}}]);this.fixScrollOffsetAndhBoxPadding();d(this).triggerHandler("jqGridGroupingClickGroup",[b,g]);d.isFunction(f.onClickGroup)&&f.onClickGroup.call(this,b,g)});return!1},groupingRender:function(b,m){function f(a,b,f,e,m){var g=y[a],p,q="",n,t,r,v=0,u,w,x,B=!0;if(0!==
  b&&0!==y[a].idx)for(p=a;0<=p;p--)if(y[p].idx===y[a].idx-b){g=y[p];break}a=g.cnt;for(u=void 0===m?e:0;u<H;u++){b="&#160;";p=z[u];for(n=0;n<g.summary.length;n++)if(t=g.summary[n],w=d.isArray(t.st)?t.st[f.idx]:t.st,x=d.isArray(p.summaryTpl)?p.summaryTpl[f.idx]:p.summaryTpl||"{0}",t.nm===p.name){"string"===typeof w&&"avg"===w.toLowerCase()&&(t.sd&&t.vd?t.v/=t.vd:t.v&&0<a&&(t.v/=a));try{t.groupCount=g.cnt,t.groupIndex=g.dataIndex,t.groupValue=g.value,r=c.formatter("",t.v,u,t)}catch(G){r=t.v}b=C.format(x,
  r);break}t=n=!1;void 0!==m&&B&&!p.hidden&&(b=m,B=!1,1<e&&(n=!0,v=e-1),t=p.align,p.align="rtl"===k.direction?"right":"left",h.iconColumnName=p.name);0<v&&!p.hidden&&"&#160;"===b?(t&&(p.align=t),v--):(q+="<td role='gridcell' "+c.formatCol(u,1,"")+(n?"colspan='"+e+"'":"")+">"+b+"</td>",t&&(p.align=t))}return q}var a="",c=this[0],k=c.p,e=0,n,q=[],u="",g,v,h=k.groupingView,w=d.makeArray(h.groupSummary),B=(h.groupCollapse?h.plusicon:h.minusicon)+" tree-wrap",r=h.groupField.length,y=h.groups,z=k.colModel,
  H=z.length,G=k.page,I=x.getGuiStyles.call(c,"gridRow","jqgroup ui-row-"+k.direction),J=x.getGuiStyles.call(c,"gridRow","jqfoot ui-row-"+k.direction);d.each(z,function(a,b){var c;for(c=0;c<r;c++)if(h.groupField[c]===b.name){q[c]=a;break}});w.reverse();d.each(y,function(x,l){if(h._locgr&&!(l.startRow+l.cnt>(G-1)*m&&l.startRow<G*m))return!0;e++;v=k.id+"ghead_"+l.idx;g=v+"_"+x;u="<span style='cursor:pointer;margin-"+("rtl"===k.direction?"right:":"left:")+12*l.idx+"px;' class='"+h.commonIconClass+" "+
  B+"' onclick=\"jQuery('#"+C.jqID(k.id).replace("\\","\\\\")+"').jqGrid('groupingToggle','"+g+"', this);return false;\"></span>";try{d.isArray(h.formatDisplayField)&&d.isFunction(h.formatDisplayField[l.idx])?(l.displayValue=h.formatDisplayField[l.idx].call(c,l.displayValue,l.value,z[q[l.idx]],l.idx,h),n=l.displayValue):n=c.formatter(g,l.displayValue,q[l.idx],l.value)}catch(K){n=l.displayValue}a+="<tr id='"+g+"' data-jqgrouplevel='"+l.idx+"' "+(h.groupCollapse&&0<l.idx?"style='display:none;' ":"")+
  "role='row' class='"+I+" "+v+"'>";var A=d.isFunction(h.groupText[l.idx])?h.groupText[l.idx].call(c,n,l.cnt,l.summary):C.template(h.groupText[l.idx],n,l.cnt,l.summary),E=1,F,D,p;p=0;D=r-1===l.idx;"string"!==typeof A&&"number"!==typeof A&&(A=n);"header"===h.groupSummaryPos[l.idx]?(E=1,"cb"!==z[0].name&&"cb"!==z[1].name||E++,"subgrid"!==z[0].name&&"subgrid"!==z[1].name||E++,a+=f(x,0,l,E,u+"<span class='cell-wrapper'>"+A+"</span>")):a+="<td role='gridcell' style='padding-left:"+12*l.idx+"px;' colspan='"+
  H+"'>"+u+A+"</td>";a+="</tr>";if(D){A=y[x+1];D=l.startRow;E=void 0!==A?A.startRow:y[x].startRow+y[x].cnt;h._locgr&&(p=(G-1)*m,p>l.startRow&&(D=p));for(;D<E&&b[D-p];D++)a+=b[D-p].join("");if("header"!==h.groupSummaryPos[l.idx]){if(void 0!==A){for(F=0;F<h.groupField.length&&A.dataIndex!==h.groupField[F];F++);e=h.groupField.length-F}for(p=0;p<e;p++)w[p]&&(a+="<tr data-jqfootlevel='"+(l.idx-p)+(h.groupCollapse&&(0<l.idx-p||!h.showSummaryOnHide)?"' style='display:none;'":"'")+" role='row' class='"+J+"'>",
  a+=f(x,p,y[l.idx-p],0),a+="</tr>");e=F}}});this.unbind("jqGridShowHideCol.groupingRender").bind("jqGridShowHideCol.groupingRender",function(){var a=k.iColByName[h.iconColumnName],b,e,f;if(0<=d.inArray("header",h.groupSummaryPos)){for(b=0;b<z.length;b++)if(!z[b].hidden){f=b;break}if(void 0!==f&&a!==f){for(b=0;b<c.rows.length;b++)e=c.rows[b],d(e).hasClass("jqgroup")&&(d(e.cells[f]).html(e.cells[a].innerHTML),d(e.cells[a]).html("&nbsp;"));h.iconColumnName=z[f].name}}});return a},groupingGroupBy:function(b,
  m){return this.each(function(){var f=this.p,a=f.groupingView,c,k;"string"===typeof b&&(b=[b]);f.grouping=!0;a._locgr=!1;void 0===a.visibiltyOnNextGrouping&&(a.visibiltyOnNextGrouping=[]);for(c=0;c<a.groupField.length;c++)k=f.colModel[f.iColByName[a.groupField[c]]],!a.groupColumnShow[c]&&a.visibiltyOnNextGrouping[c]&&null!=k&&!0===k.hidden&&x.showCol.call(d(this),a.groupField[c]);for(c=0;c<b.length;c++)a.visibiltyOnNextGrouping[c]=d(f.idSel+"_"+C.jqID(b[c])).is(":visible");f.groupingView=d.extend(f.groupingView,
  m||{});a.groupField=b;d(this).trigger("reloadGrid")})},groupingRemove:function(b){return this.each(function(){var m=this.p,f=this.tBodies[0],a=m.groupingView;void 0===b&&(b=!0);m.grouping=!1;if(!0===b){for(m=0;m<a.groupField.length;m++)!a.groupColumnShow[m]&&a.visibiltyOnNextGrouping[m]&&x.showCol.call(d(this),a.groupField);d("tr.jqgroup, tr.jqfoot",f).remove();d("tr.jqgrow",f).filter(":hidden").show()}else d(this).trigger("reloadGrid")})},groupingCalculations:{handler:function(b,d,f,a,c,k){var e=
  {sum:function(){return parseFloat(d||0)+parseFloat(k[f]||0)},min:function(){return""===d?parseFloat(k[f]||0):Math.min(parseFloat(d),parseFloat(k[f]||0))},max:function(){return""===d?parseFloat(k[f]||0):Math.max(parseFloat(d),parseFloat(k[f]||0))},count:function(){""===d&&(d=0);return k.hasOwnProperty(f)?d+1:0},avg:function(){return e.sum()}};if(!e[b])throw"jqGrid Grouping No such method: "+b;b=e[b]();null!=a&&("fixed"===c?b=b.toFixed(a):(a=Math.pow(10,a),b=Math.round(b*a)/a));return b}}})});
  //# sourceMappingURL=grid.grouping.map
  