EVOLUTION-NINJA
Edit File: grid.treegrid.js
!function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery","./grid.base"],e):e(jQuery)}(function(e){"use strict";e.jgrid.extend({setTreeNode:function(r,t){return this.each(function(){var i=this;if(i.grid&&i.p.treeGrid){var d,a,s,l,n,p,o,h,c=i.p.expColInd,f=i.p.treeReader.expanded_field,u=i.p.treeReader.leaf_field,g=i.p.treeReader.level_field,v=i.p.treeReader.icon_field,G=i.p.treeReader.loaded,_=e.jgrid.styleUI[i.p.styleUI||"jQueryUI"].common,R=r;for(e(i).triggerHandler("jqGridBeforeSetTreeNode",[R,t]),e.isFunction(i.p.beforeSetTreeNode)&&i.p.beforeSetTreeNode.call(i,R,t);r<t;){var j=e.jgrid.stripPref(i.p.idPrefix,i.rows[r].id),I=i.p._index[j];o=i.p.data[I],"nested"===i.p.treeGridModel&&(o[u]||(d=parseInt(o[i.p.treeReader.left_field],10),a=parseInt(o[i.p.treeReader.right_field],10),o[u]=a===d+1?"true":"false",i.rows[r].cells[i.p._treeleafpos].innerHTML=o[u])),s=parseInt(o[g],10),0===i.p.tree_root_level?(l=s+1,n=s):(l=s,n=s-1),p="<div class='tree-wrap tree-wrap-"+i.p.direction+"' style='width:"+18*l+"px;'>",p+="<div style='"+("rtl"===i.p.direction?"right:":"left:")+18*n+"px;' class='"+_.icon_base+" ",void 0!==o[G]&&("true"===o[G]||!0===o[G]?o[G]=!0:o[G]=!1),"true"===o[u]||!0===o[u]?(p+=(void 0!==o[v]&&""!==o[v]?o[v]:i.p.treeIcons.leaf)+" tree-leaf treeclick",o[u]=!0,h="leaf"):(o[u]=!1,h=""),o[f]=("true"===o[f]||!0===o[f])&&(o[G]||void 0===o[G]),!1===o[f]?p+=!0===o[u]?"'":i.p.treeIcons.plus+" tree-plus treeclick'":p+=!0===o[u]?"'":i.p.treeIcons.minus+" tree-minus treeclick'",p+="></div></div>",e(i.rows[r].cells[c]).wrapInner("<span class='cell-wrapper"+h+"'></span>").prepend(p),s!==parseInt(i.p.tree_root_level,10)&&(e(i).jqGrid("isVisibleNode",o)||e(i.rows[r]).css("display","none")),e(i.rows[r].cells[c]).find("div.treeclick").on("click",function(r){var t=r.target||r.srcElement,d=e.jgrid.stripPref(i.p.idPrefix,e(t,i.rows).closest("tr.jqgrow")[0].id),a=i.p._index[d];return i.p.data[a][u]||(i.p.data[a][f]?(e(i).jqGrid("collapseRow",i.p.data[a]),e(i).jqGrid("collapseNode",i.p.data[a])):(e(i).jqGrid("expandRow",i.p.data[a]),e(i).jqGrid("expandNode",i.p.data[a]))),!1}),!0===i.p.ExpandColClick&&e(i.rows[r].cells[c]).find("span.cell-wrapper").css("cursor","pointer").on("click",function(r){var t=r.target||r.srcElement,d=e.jgrid.stripPref(i.p.idPrefix,e(t,i.rows).closest("tr.jqgrow")[0].id),a=i.p._index[d];return i.p.data[a][u]||(i.p.data[a][f]?(e(i).jqGrid("collapseRow",i.p.data[a]),e(i).jqGrid("collapseNode",i.p.data[a])):(e(i).jqGrid("expandRow",i.p.data[a]),e(i).jqGrid("expandNode",i.p.data[a]))),e(i).jqGrid("setSelection",d),!1}),r++}e(i).triggerHandler("jqGridAfterSetTreeNode",[R,t]),e.isFunction(i.p.afterSetTreeNode)&&i.p.afterSetTreeNode.call(i,R,t)}})},setTreeGrid:function(){return this.each(function(){var r,t,i,d,a=this,s=0,l=!1,n=[],p=e.jgrid.styleUI[a.p.styleUI||"jQueryUI"].treegrid;if(a.p.treeGrid){for(i in a.p.treedatatype||e.extend(a.p,{treedatatype:a.p.datatype}),a.p.loadonce&&(a.p.treedatatype="local"),a.p.subGrid=!1,a.p.altRows=!1,a.p.pgbuttons=!1,a.p.pginput=!1,a.p.gridview=!0,null===a.p.rowTotal&&(a.p.rowNum=1e4),a.p.multiselect=!1,a.p.rowList=[],a.p.expColInd=0,r=p.icon_plus,"jQueryUI"===a.p.styleUI&&(r+="rtl"===a.p.direction?"w":"e"),a.p.treeIcons=e.extend({plus:r,minus:p.icon_minus,leaf:p.icon_leaf},a.p.treeIcons||{}),"nested"===a.p.treeGridModel?a.p.treeReader=e.extend({level_field:"level",left_field:"lft",right_field:"rgt",leaf_field:"isLeaf",expanded_field:"expanded",loaded:"loaded",icon_field:"icon"},a.p.treeReader):"adjacency"===a.p.treeGridModel&&(a.p.treeReader=e.extend({level_field:"level",parent_id_field:"parent",leaf_field:"isLeaf",expanded_field:"expanded",loaded:"loaded",icon_field:"icon"},a.p.treeReader)),a.p.colModel)if(a.p.colModel.hasOwnProperty(i))for(d in(t=a.p.colModel[i].name)!==a.p.ExpandColumn||l||(l=!0,a.p.expColInd=s),s++,a.p.treeReader)a.p.treeReader.hasOwnProperty(d)&&a.p.treeReader[d]===t&&n.push(t);e.each(a.p.treeReader,function(r,t){t&&-1===e.inArray(t,n)&&("leaf_field"===r&&(a.p._treeleafpos=s),s++,a.p.colNames.push(t),a.p.colModel.push({name:t,width:1,hidden:!0,sortable:!1,resizable:!1,hidedlg:!0,editable:!0,search:!1}))})}})},expandRow:function(r){this.each(function(){var t=this;if(t.grid&&t.p.treeGrid){var i=e(t).jqGrid("getNodeChildren",r),d=t.p.treeReader.expanded_field,a=r[t.p.localReader.id];!1!==(!e.isFunction(t.p.beforeExpandTreeGridRow)||t.p.beforeExpandTreeGridRow.call(t,a,r,i))&&(e(i).each(function(){var r=t.p.idPrefix+e.jgrid.getAccessor(this,t.p.localReader.id);e(e(t).jqGrid("getGridRowById",r)).css("display",""),this[d]&&e(t).jqGrid("expandRow",this)}),e.isFunction(t.p.afterExpandTreeGridRow)&&t.p.afterExpandTreeGridRow.call(t,a,r,i))}})},collapseRow:function(r){this.each(function(){var t=this;if(t.grid&&t.p.treeGrid){var i=e(t).jqGrid("getNodeChildren",r),d=t.p.treeReader.expanded_field,a=r[t.p.localReader.id];!1!==(!e.isFunction(t.p.beforeCollapseTreeGridRow)||t.p.beforeCollapseTreeGridRow.call(t,a,r,i))&&(e(i).each(function(){var r=t.p.idPrefix+e.jgrid.getAccessor(this,t.p.localReader.id);e(e(t).jqGrid("getGridRowById",r)).css("display","none"),this[d]&&e(t).jqGrid("collapseRow",this)}),e.isFunction(t.p.afterCollapseTreeGridRow)&&t.p.afterCollapseTreeGridRow.call(t,a,r,i))}})},getRootNodes:function(r){var t=[];return this.each(function(){var i,d,a,s=this;if(s.grid&&s.p.treeGrid)switch("boolean"!=typeof r&&(r=!1),a=r?e(s).jqGrid("getRowData",null,!0):s.p.data,s.p.treeGridModel){case"nested":i=s.p.treeReader.level_field,e(a).each(function(){parseInt(this[i],10)===parseInt(s.p.tree_root_level,10)&&(r?t.push(s.p.data[s.p._index[this[s.p.keyName]]]):t.push(this))});break;case"adjacency":d=s.p.treeReader.parent_id_field,e(a).each(function(){null!==this[d]&&"null"!==String(this[d]).toLowerCase()||(r?t.push(s.p.data[s.p._index[this[s.p.keyName]]]):t.push(this))})}}),t},getNodeDepth:function(r){var t=null;return this.each(function(){if(this.grid&&this.p.treeGrid){switch(this.p.treeGridModel){case"nested":var i=this.p.treeReader.level_field;t=parseInt(r[i],10)-parseInt(this.p.tree_root_level,10);break;case"adjacency":t=e(this).jqGrid("getNodeAncestors",r).length}}}),t},getNodeParent:function(r){var t=null;return this.each(function(){var i=this;if(i.grid&&i.p.treeGrid)switch(i.p.treeGridModel){case"nested":var d=i.p.treeReader.left_field,a=i.p.treeReader.right_field,s=i.p.treeReader.level_field,l=parseInt(r[d],10),n=parseInt(r[a],10),p=parseInt(r[s],10);e(this.p.data).each(function(){if(parseInt(this[s],10)===p-1&&parseInt(this[d],10)<l&&parseInt(this[a],10)>n)return t=this,!1});break;case"adjacency":for(var o=i.p.treeReader.parent_id_field,h=i.p.localReader.id,c=r[h],f=i.p._index[c];f--;)if(i.p.data[f][h]===e.jgrid.stripPref(i.p.idPrefix,r[o])){t=i.p.data[f];break}}}),t},getNodeChildren:function(r,t){var i=[];return this.each(function(){var d=this;if(d.grid&&d.p.treeGrid){var a,s,l=t?this.rows.length:this.p.data.length;switch(d.p.treeGridModel){case"nested":var n=d.p.treeReader.left_field,p=d.p.treeReader.right_field,o=d.p.treeReader.level_field,h=parseInt(r[n],10),c=parseInt(r[p],10),f=parseInt(r[o],10);for(a=0;a<l;a++)(s=t?d.p.data[d.p._index[this.rows[a].id]]:d.p.data[a])&&parseInt(s[o],10)===f+1&&parseInt(s[n],10)>h&&parseInt(s[p],10)<c&&i.push(s);break;case"adjacency":var u=d.p.treeReader.parent_id_field,g=d.p.localReader.id;for(a=0;a<l;a++)(s=t?d.p.data[d.p._index[this.rows[a].id]]:d.p.data[a])&&String(s[u])===e.jgrid.stripPref(d.p.idPrefix,r[g])&&i.push(s)}}}),i},getFullTreeNode:function(r,t){var i=[];return this.each(function(){var d,a=this,s=a.p.treeReader.expanded_field;if(a.grid&&a.p.treeGrid)switch(null!=t&&"boolean"==typeof t||(t=!1),a.p.treeGridModel){case"nested":var l=a.p.treeReader.left_field,n=a.p.treeReader.right_field,p=a.p.treeReader.level_field,o=parseInt(r[l],10),h=parseInt(r[n],10),c=parseInt(r[p],10);e(this.p.data).each(function(){parseInt(this[p],10)>=c&&parseInt(this[l],10)>=o&&parseInt(this[l],10)<=h&&(t&&(this[s]=!0),i.push(this))});break;case"adjacency":if(r){i.push(r);var f=a.p.treeReader.parent_id_field,u=a.p.localReader.id;e(this.p.data).each(function(r){for(d=i.length,r=0;r<d;r++)if(e.jgrid.stripPref(a.p.idPrefix,i[r][u])===this[f]){t&&(this[s]=!0),i.push(this);break}})}}}),i},getNodeAncestors:function(r,t,i){var d=[];return void 0===t&&(t=!1),this.each(function(){if(this.grid&&this.p.treeGrid){i=void 0!==i&&this.p.treeReader.expanded_field;for(var a=e(this).jqGrid("getNodeParent",r);a;){if(i)try{a[i]=!0}catch(e){}t?d.unshift(a):d.push(a),a=e(this).jqGrid("getNodeParent",a)}}}),d},isVisibleNode:function(r){var t=!0;return this.each(function(){if(this.grid&&this.p.treeGrid){var i=e(this).jqGrid("getNodeAncestors",r),d=this.p.treeReader.expanded_field;e(i).each(function(){if(!(t=t&&this[d]))return!1})}}),t},isNodeLoaded:function(r){var t;return this.each(function(){var i=this;if(i.grid&&i.p.treeGrid){var d=i.p.treeReader.leaf_field,a=i.p.treeReader.loaded;t=void 0!==r&&(void 0!==r[a]?r[a]:!!(r[d]||e(i).jqGrid("getNodeChildren",r).length>0))}}),t},setLeaf:function(r,t,i){return this.each(function(){var d=e.jgrid.getAccessor(r,this.p.localReader.id),a=e("#"+d,this.grid.bDiv)[0],s=this.p.treeReader.leaf_field;try{var l=this.p._index[d];null!=l&&(this.p.data[l][s]=t)}catch(e){}if(!0===t)e("div.treeclick",a).removeClass(this.p.treeIcons.minus+" tree-minus "+this.p.treeIcons.plus+" tree-plus").addClass(this.p.treeIcons.leaf+" tree-leaf");else if(!1===t){var n=this.p.treeIcons.minus+" tree-minus";i&&(n=this.p.treeIcons.plus+" tree-plus"),e("div.treeclick",a).removeClass(this.p.treeIcons.leaf+" tree-leaf").addClass(n)}})},reloadNode:function(r,t){return this.each(function(){if(this.grid&&this.p.treeGrid){var i=this.p.localReader.id,d=this.p.selrow;e(this).jqGrid("delChildren",r[i]),void 0===t&&(t=!1),t||jQuery._data(this,"events").jqGridAfterSetTreeNode||e(this).on("jqGridAfterSetTreeNode.reloadNode",function(){var r=this.p.treeReader.leaf_field;if(this.p.reloadnode){var t=this.p.reloadnode,i=e(this).jqGrid("getNodeChildren",t);t[r]&&i.length?e(this).jqGrid("setLeaf",t,!1):t[r]||0!==i.length||e(this).jqGrid("setLeaf",t,!0)}this.p.reloadnode=!1});var a=this.p.treeReader.expanded_field,s=this.p.treeReader.parent_id_field,l=this.p.treeReader.loaded,n=this.p.treeReader.level_field,p=this.p.treeReader.leaf_field,o=this.p.treeReader.left_field,h=this.p.treeReader.right_field,c=e.jgrid.getAccessor(r,this.p.localReader.id),f=e("#"+c,this.grid.bDiv)[0];r[a]=!0,r[p]||e("div.treeclick",f).removeClass(this.p.treeIcons.plus+" tree-plus").addClass(this.p.treeIcons.minus+" tree-minus"),this.p.treeANode=f.rowIndex,this.p.datatype=this.p.treedatatype,this.p.reloadnode=r,t&&(this.p.treeANode=f.rowIndex>0?f.rowIndex-1:1,e(this).jqGrid("delRowData",c)),"nested"===this.p.treeGridModel?e(this).jqGrid("setGridParam",{postData:{nodeid:c,n_left:r[o],n_right:r[h],n_level:r[n]}}):e(this).jqGrid("setGridParam",{postData:{nodeid:c,parentid:r[s],n_level:r[n]}}),e(this).trigger("reloadGrid"),r[l]=!0,"nested"===this.p.treeGridModel?e(this).jqGrid("setGridParam",{selrow:d,postData:{nodeid:"",n_left:"",n_right:"",n_level:""}}):e(this).jqGrid("setGridParam",{selrow:d,postData:{nodeid:"",parentid:"",n_level:""}})}})},expandNode:function(r){return this.each(function(){if(this.grid&&this.p.treeGrid){var t=this.p.treeReader.expanded_field,i=this.p.treeReader.parent_id_field,d=this.p.treeReader.loaded,a=this.p.treeReader.level_field,s=this.p.treeReader.left_field,l=this.p.treeReader.right_field;if(!r[t]){var n=e.jgrid.getAccessor(r,this.p.localReader.id),p=e("#"+this.p.idPrefix+e.jgrid.jqID(n),this.grid.bDiv)[0],o=this.p._index[n];if(!1===(!e.isFunction(this.p.beforeExpandTreeGridNode)||this.p.beforeExpandTreeGridNode.call(this,n,r)))return;e(this).jqGrid("isNodeLoaded",this.p.data[o])?(r[t]=!0,e("div.treeclick",p).removeClass(this.p.treeIcons.plus+" tree-plus").addClass(this.p.treeIcons.minus+" tree-minus")):this.grid.hDiv.loading||(r[t]=!0,e("div.treeclick",p).removeClass(this.p.treeIcons.plus+" tree-plus").addClass(this.p.treeIcons.minus+" tree-minus"),this.p.treeANode=p.rowIndex,this.p.datatype=this.p.treedatatype,"nested"===this.p.treeGridModel?e(this).jqGrid("setGridParam",{postData:{nodeid:n,n_left:r[s],n_right:r[l],n_level:r[a]}}):e(this).jqGrid("setGridParam",{postData:{nodeid:n,parentid:r[i],n_level:r[a]}}),e(this).trigger("reloadGrid"),r[d]=!0,"nested"===this.p.treeGridModel?e(this).jqGrid("setGridParam",{postData:{nodeid:"",n_left:"",n_right:"",n_level:""}}):e(this).jqGrid("setGridParam",{postData:{nodeid:"",parentid:"",n_level:""}})),e.isFunction(this.p.afterExpandTreeGridNode)&&this.p.afterExpandTreeGridNode.call(this,n,r)}}})},collapseNode:function(r){return this.each(function(){if(this.grid&&this.p.treeGrid){var t=this.p.treeReader.expanded_field;if(r[t]){var i=e.jgrid.getAccessor(r,this.p.localReader.id),d=!e.isFunction(this.p.beforeCollapseTreeGridNode)||this.p.beforeCollapseTreeGridNode.call(this,i,r),a=e("#"+this.p.idPrefix+e.jgrid.jqID(i),this.grid.bDiv)[0];if(r[t]=!1,!1===d)return;e("div.treeclick",a).removeClass(this.p.treeIcons.minus+" tree-minus").addClass(this.p.treeIcons.plus+" tree-plus"),e.isFunction(this.p.afterCollapseTreeGridNode)&&this.p.afterCollapseTreeGridNode.call(this,i,r)}}})},SortTree:function(r,t,i,d){return this.each(function(){if(this.grid&&this.p.treeGrid){var a,s,l,n,p,o=[],h=this,c=e(this).jqGrid("getRootNodes",h.p.search);for((n=e.jgrid.from.call(this,c)).orderBy(r,t,i,d),a=0,s=(p=n.select()).length;a<s;a++)l=p[a],o.push(l),e(this).jqGrid("collectChildrenSortTree",o,l,r,t,i,d);e.each(o,function(r){var t=e.jgrid.getAccessor(this,h.p.localReader.id);e("#"+e.jgrid.jqID(h.p.id)+" tbody tr:eq("+r+")").after(e("tr#"+e.jgrid.jqID(t),h.grid.bDiv))}),n=null,p=null,o=null}})},searchTree:function(r){var t,i,d,a,s,l,n=r.length||0,p=[],o=[],h=[];return this.each(function(){if(this.grid&&this.p.treeGrid&&n)for(t=this.p.localReader.id;n--;)if((p=e(this).jqGrid("getNodeAncestors",r[n],!0,!0)).push(r[n]),i=p[0][t],-1===e.inArray(i,o))o.push(i),h=h.concat(p);else for(s=0,d=p.length;s<d;s++){var c=!1;for(l=0,a=h.length;l<a;l++)if(p[s][t]===h[l][t]){c=!0;break}c||h.push(p[s])}}),h},collectChildrenSortTree:function(r,t,i,d,a,s){return this.each(function(){var l,n,p,o,h,c;if(this.grid&&this.p.treeGrid)for(o=e(this).jqGrid("getNodeChildren",t,this.p.search),(h=e.jgrid.from.call(this,o)).orderBy(i,d,a,s),l=0,n=(c=h.select()).length;l<n;l++)p=c[l],r.push(p),e(this).jqGrid("collectChildrenSortTree",r,p,i,d,a,s)})},setTreeRow:function(r,t){var i=!1;return this.each(function(){var d=this;d.grid&&d.p.treeGrid&&(i=e(d).jqGrid("setRowData",r,t))}),i},delTreeNode:function(r){return this.each(function(){var t,i,d,a,s,l=this,n=l.p.localReader.id,p=l.p.treeReader.left_field,o=l.p.treeReader.right_field;if(l.grid&&l.p.treeGrid){var h=l.p._index[r];if(void 0!==h){d=(i=parseInt(l.p.data[h][o],10))-parseInt(l.p.data[h][p],10)+1;var c=e(l).jqGrid("getFullTreeNode",l.p.data[h]);if(c.length>0)for(t=0;t<c.length;t++)e(l).jqGrid("delRowData",c[t][n]);if("nested"===l.p.treeGridModel){if((a=e.jgrid.from.call(l,l.p.data).greater(p,i,{stype:"integer"}).select()).length)for(s in a)a.hasOwnProperty(s)&&(a[s][p]=parseInt(a[s][p],10)-d);if((a=e.jgrid.from.call(l,l.p.data).greater(o,i,{stype:"integer"}).select()).length)for(s in a)a.hasOwnProperty(s)&&(a[s][o]=parseInt(a[s][o],10)-d)}}}})},delChildren:function(r){return this.each(function(){var t,i,d,a,s=this,l=s.p.localReader.id,n=s.p.treeReader.left_field,p=s.p.treeReader.right_field;if(s.grid&&s.p.treeGrid){var o=s.p._index[r];if(void 0!==o){i=(t=parseInt(s.p.data[o][p],10))-parseInt(s.p.data[o][n],10)+1;var h=e(s).jqGrid("getFullTreeNode",s.p.data[o]);if(h.length>0)for(var c=0;c<h.length;c++)h[c][l]!==r&&e(s).jqGrid("delRowData",h[c][l]);if("nested"===s.p.treeGridModel){if((d=e.jgrid.from(s.p.data).greater(n,t,{stype:"integer"}).select()).length)for(a in d)d.hasOwnProperty(a)&&(d[a][n]=parseInt(d[a][n],10)-i);if((d=e.jgrid.from(s.p.data).greater(p,t,{stype:"integer"}).select()).length)for(a in d)d.hasOwnProperty(a)&&(d[a][p]=parseInt(d[a][p],10)-i)}}}})},addChildNode:function(r,t,i,d){var a=this[0];if(i){var s,l,n,p,o,h,c,f,u=a.p.treeReader.expanded_field,g=a.p.treeReader.leaf_field,v=a.p.treeReader.level_field,G=a.p.treeReader.parent_id_field,_=a.p.treeReader.left_field,R=a.p.treeReader.right_field,j=a.p.treeReader.loaded,I=0,w=t;if(void 0===d&&(d=!1),null==r){if((o=a.p.data.length-1)>=0)for(;o>=0;)I=Math.max(I,parseInt(a.p.data[o][a.p.localReader.id],10)),o--;r=I+1}var x,q,y=e(a).jqGrid("getInd",t);if(c=!1,null==t||""===t)t=null,w=null,s="last",p=a.p.tree_root_level,o=a.p.data.length+1;else{s="after",l=a.p._index[t],t=(n=a.p.data[l])[a.p.localReader.id],p=parseInt(n[v],10)+1;var N=e(a).jqGrid("getFullTreeNode",n);N.length?(w=o=N[N.length-1][a.p.localReader.id],o=e(a).jqGrid("getInd",w)+1):o=e(a).jqGrid("getInd",t)+1,n[g]&&(c=!0,n[u]=!0,e(a.rows[y]).find("span.cell-wrapperleaf").removeClass("cell-wrapperleaf").addClass("cell-wrapper").end().find("div.tree-leaf").removeClass(a.p.treeIcons.leaf+" tree-leaf").addClass(a.p.treeIcons.minus+" tree-minus"),a.p.data[l][g]=!1,n[j]=!0)}if(h=o+1,void 0===i[u]&&(i[u]=!1),void 0===i[j]&&(i[j]=!1),i[v]=p,void 0===i[g]&&(i[g]=!0),"adjacency"===a.p.treeGridModel&&(i[G]=t),"nested"===a.p.treeGridModel)if(null!==t){if(f=parseInt(n[R],10),(x=e.jgrid.from.call(a,a.p.data).greaterOrEquals(R,f,{stype:"integer"}).select()).length)for(q in x)x.hasOwnProperty(q)&&(x[q][_]=x[q][_]>f?parseInt(x[q][_],10)+2:x[q][_],x[q][R]=x[q][R]>=f?parseInt(x[q][R],10)+2:x[q][R]);i[_]=f,i[R]=f+1}else{if(f=parseInt(e(a).jqGrid("getCol",R,!1,"max"),10),(x=e.jgrid.from.call(a,a.p.data).greater(_,f,{stype:"integer"}).select()).length)for(q in x)x.hasOwnProperty(q)&&(x[q][_]=parseInt(x[q][_],10)+2);if((x=e.jgrid.from.call(a,a.p.data).greater(R,f,{stype:"integer"}).select()).length)for(q in x)x.hasOwnProperty(q)&&(x[q][R]=parseInt(x[q][R],10)+2);i[_]=f+1,i[R]=f+2}(null===t||e(a).jqGrid("isNodeLoaded",n)||c)&&(e(a).jqGrid("addRowData",r,i,s,w),e(a).jqGrid("setTreeNode",o,h)),n&&!n[u]&&d&&e(a.rows[y]).find("div.treeclick").click()}}})});