text: !function(t){"use strict";"function"==typeof define&&define.amd?define(["jquery","./grid.base"],t):"object"==typeof module&&module.exports?module.exports=function(i,s){return i||(i=window),void 0===s&&(s="undefined"!=typeof window?require("jquery"):require("jquery")(i)),require("./grid.base"),t(s),s}:t(jQuery)}(function(x){"use strict";var w=x.jgrid,S=w.jqID,C=x.fn.jqGrid,O=function(){var i=x.makeArray(arguments);return i[0]="subGrid"+i[0].charAt(0).toUpperCase()+i[0].substring(1),i.unshift(""),i.unshift(""),i.unshift(this.p),w.feedback.apply(this,i)},s=function(s,t){return this.each(function(){if(this.grid&&null!=s&&!0===this.p.subGrid){var i=x(this).jqGrid("getInd",s,!0);x(i).find(">td."+t).trigger("click")}})};w.extend({setSubGrid:function(){return this.each(function(){var i,s=this.p,t=x(this),e=s.subGridModel[0],r=function(i){return t.jqGrid("getIconRes",i)};if(s.subGridOptions=x.extend({commonIconClass:r("subgrid.common"),plusicon:r("subgrid.plus"),minusicon:r("subgrid.minus"),openicon:"rtl"===s.direction?r("subgrid.openRtl"):r("subgrid.openLtr"),expandOnLoad:!1,delayOnLoad:50,selectOnExpand:!1,selectOnCollapse:!1,reloadOnExpand:!0},s.subGridOptions||{}),s.colNames.unshift(""),s.colModel.unshift({name:"subgrid",width:w.cell_width?s.subGridWidth+s.cellLayout:s.subGridWidth,labelClasses:"jqgh_subgrid",sortable:!1,resizable:!1,hidedlg:!0,search:!1,fixed:!0,frozen:!0}),e)for(e.align=x.extend([],e.align||[]),i=0;i<e.name.length;i++)e.align[i]=e.align[i]||"left"})},addSubGridCell:function(i,s,t,e){var r=this[0],n=r.p.subGridOptions,l=!x.isFunction(n.hasSubgrid)||n.hasSubgrid.call(r,{rowid:t,iRow:s,iCol:i,data:e});return null==r.p?"":"<td role='gridcell' class='"+C.getGuiStyles.call(this,"subgrid.tdStart",l?"ui-sgcollapsed sgcollapsed":"")+"' "+r.formatCol(i,s)+">"+(l?"<div class='"+C.getGuiStyles.call(this,"subgrid.buttonDiv","sgbutton-div")+"'><a role='button' class='"+C.getGuiStyles.call(this,"subgrid.button","sgbutton")+"'><span class='"+w.mergeCssClasses(n.commonIconClass,n.plusicon)+"'></span></a></div>":"&nbsp;")+"</td>"},addSubGrid:function(v,l){return this.each(function(){var i,s,t,d=this,o=d.p,u=o.subGridModel[0],c=function(i,s){return C.getGuiStyles.call(d,"subgrid."+i,s||"")},g=c("thSubgrid","ui-th-subgrid ui-th-column ui-th-"+o.direction),p=c("rowSubTable","ui-subtblcell"),a=c("row","ui-subgrid ui-row-"+o.direction),b=c("tdWithIcon","subgrid-cell"),h=c("tdData","subgrid-data"),f=function(i,s,t){var e=u.align[t],r=x("<td"+(e?" style='text-align:"+e+";'":"")+"></td>").html(s);i.append(r)},m=function(i,e){var r=o.xmlReader.subgrid;x(r.root+" "+r.row,i).each(function(){var i,s,t=x("<tr class='"+p+"'></tr>");if(!0===r.repeatitems)x(r.cell,this).each(function(i){f(t,x(this).text()||"&#160;",i)});else if(i=u.mapping||u.name)for(s=0;s<i.length;s++)f(t,w.getXmlData(this,i[s])||"&#160;",s);e.append(t)})},G=function(i,s){var t,e,r,n,l,a=o.jsonReader.subgrid,d=w.getAccessor(i,a.root);if(null!=d)for(e=0;e<d.length;e++){if(l=d[e],t=x("<tr class='"+p+"'></tr>"),!0===a.repeatitems)for(a.cell&&(l=l[a.cell]),r=0;r<l.length;r++)f(t,l[r]||"&#160;",r);else if((n=u.mapping||u.name).length)for(r=0;r<n.length;r++)f(t,w.getAccessor(l,n[r])||"&#160;",r);s.append(t)}},y=function(i,s,t){var e,r,n=c("legacyTable","ui-jqgrid-legacy-subgrid"+(!0===o.altRows&&x(d).jqGrid("isBootstrapGuiStyle")?" table-striped":"")),l=x("<table"+(n?" style='width:1px' role='presentation' class='"+n+"'":"")+"><thead></thead><tbody></tbody></table>"),a=x("<tr></tr>");for(d.grid.endReq.call(d),r=0;r<u.name.length;r++)e=x("<th class='"+g+"'></th>").html(u.name[r]).width(u.width[r]),a.append(e);return a.appendTo(l[0].tHead),t(i,x(l[0].tBodies[0])),x("#"+S(o.id+"_"+s)).append(l),!1},e=function(){var i,s=x(this).parent("tr")[0],t=s.nextSibling,e=s.id,r=o.id+"_"+e,n=function(i){return w.mergeCssClasses(o.subGridOptions.commonIconClass,o.subGridOptions[i])},l=1;if(x.each(o.colModel,function(){!0!==this.hidden&&"rn"!==this.name&&"cb"!==this.name||l++}),x(this).hasClass("sgcollapsed")){if(!0===o.subGridOptions.reloadOnExpand||!1===o.subGridOptions.reloadOnExpand&&!x(t).hasClass("ui-subgrid")){if(i=1<=v?"<td colspan='"+v+"'>&#160;</td>":"",!O.call(d,"beforeExpand",r,e))return;x(s).after("<tr role='row' class='"+a+"'>"+i+"<td class='"+b+"'><span class='"+n("openicon")+"'></span></td><td colspan='"+parseInt(o.colNames.length-l,10)+"' class='"+h+"'><div id='"+r+"' class='tablediv'></div></td></tr>"),x(d).triggerHandler("jqGridSubGridRowExpanded",[r,e]),x.isFunction(o.subGridRowExpanded)?o.subGridRowExpanded.call(d,r,e):function(i){var s,t,e=x(i).attr("id"),r={nd_:(new Date).getTime()};if(r[o.prmNames.subgridid]=e,!u)return;if(u.params)for(t=0;t<u.params.length;t++)void 0!==(s=o.iColByName[u.params[t]])&&(r[o.colModel[s].name]=x(i.cells[s]).text().replace(/\&#160\;/gi,""));if(!d.grid.hDiv.loading)switch(d.grid.beginReq.call(d),o.subgridtype||(o.subgridtype=o.datatype),x.isFunction(o.subgridtype)?o.subgridtype.call(d,r):o.subgridtype=o.subgridtype.toLowerCase(),o.subgridtype){case"xml":case"json":x.ajax(x.extend({type:o.mtype,url:x.isFunction(o.subGridUrl)?o.subGridUrl.call(d,r):o.subGridUrl,dataType:o.subgridtype,context:e,data:w.serializeFeedback.call(d,o.serializeSubGridData,"jqGridSerializeSubGridData",r),success:function(i){y(i,this,"xml"===o.subgridtype?m:G)},error:function(i,s,t){var e=void 0===o.loadSubgridError?o.loadError:o.loadSubgridError;d.grid.endReq.call(d),x.isFunction(e)&&e.call(d,i,s,t),o.subGridOptions.noEmptySubgridOnError||y(null,this,"xml"===o.subgridtype?m:G)}},w.ajaxOptions,o.ajaxSubgridOptions||{}))}}(s)}else x(t).show();x(this).html("<div class='"+C.getGuiStyles.call(d,"subgrid.buttonDiv","sgbutton-div")+"'><a role='button' class='"+C.getGuiStyles.call(d,"subgrid.button","sgbutton")+"'><span class='"+n("minusicon")+"'></span></a></div>").removeClass("sgcollapsed").addClass("sgexpanded"),o.subGridOptions.selectOnExpand&&x(d).jqGrid("setSelection",e)}else if(x(this).hasClass("sgexpanded")){if(!O.call(d,"beforeCollapse",r,e))return;!0===o.subGridOptions.reloadOnExpand?x(t).remove(".ui-subgrid"):x(t).hasClass("ui-subgrid")&&x(t).hide(),x(this).html("<div class='"+C.getGuiStyles.call(d,"subgrid.buttonDiv","sgbutton-div")+"'><a role='button' class='"+C.getGuiStyles.call(d,"subgrid.button","sgbutton")+"'><span class='"+n("plusicon")+"'></span></a></div>").removeClass("sgexpanded").addClass("sgcollapsed"),o.subGridOptions.selectOnCollapse&&x(d).jqGrid("setSelection",e)}return!1},r=1;if(d.grid){for(i=d.rows.length,void 0!==l&&0<l&&(i=(r=l)+1);r<i;)s=d.rows[r],x(s).hasClass("jqgrow")&&(t=x(s.cells[v])).hasClass("ui-sgcollapsed")&&(o.scroll&&t.off("click"),t.on("click",e)),r++;if(!0===o.subGridOptions.expandOnLoad){var n=o.iColByName.subgrid;x(d.rows).filter(".jqgrow").each(function(i,s){x(s.cells[n]).filter(".sgcollapsed").children(".sgbutton-div").children(".sgbutton").click()})}d.subGridXml=function(i,s){return y(i,s,m)},d.subGridJson=function(i,s){return y(i,s,G)}}})},expandSubGridRow:function(i){return s.call(this,i,"sgcollapsed")},collapseSubGridRow:function(i){return s.call(this,i,"sgexpanded")},toggleSubGridRow:function(i){return s.call(this,i,"ui-sgcollapsed")}})});
  //# sourceMappingURL=grid.subgrid.js.map