;(function($){ /** * jqGrid extension for SubGrid Data * Tony Tomov tony@trirand.com * http://trirand.com/blog/ * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html **/ $.fn.extend({ addSubGrid : function(t,row,pos,rowelem) { return this.each(function(){ var ts = this; if (!ts.grid ) { return; } var td, res,_id, pID, nhc, bfsc; td = document.createElement("td"); $(td,t).html("").addClass("sgcollapsed") .click( function(e) { if($(this).hasClass("sgcollapsed")) { pID = $("table:first",ts.grid.bDiv).attr("id"); res = $(this).parent(); var atd= pos==1?'':''; _id = $(res).attr("id"); bfsc =true; if($.isFunction(ts.p.subGridBeforeExpand)) { bfsc = ts.p.subGridBeforeExpand(pID+"_"+_id,_id); } if(bfsc === false) {return false;} nhc = 0; $.each(ts.p.colModel,function(i,v){ if(this.hidden === true) { nhc++; } }); var subdata = ""+atd+"
"; $(this).parent().after( subdata+ "
" ); $(".tablediv",ts).css("width", ts.grid.width-20+"px"); if( $.isFunction(ts.p.subGridRowExpanded) ) { ts.p.subGridRowExpanded(pID+"_"+ _id,_id); } else { populatesubgrid(res); } $(this).html("").removeClass("sgcollapsed").addClass("sgexpanded"); } else if($(this).hasClass("sgexpanded")) { bfsc = true; if( $.isFunction(ts.p.subGridRowColapsed)) { res = $(this).parent(); _id = $(res).attr("id"); bfsc = ts.p.subGridRowColapsed(pID+"_"+_id,_id ); }; if(bfsc===false) {return false;} $(this).parent().next().remove(".subgrid"); $(this).html("").removeClass("sgexpanded").addClass("sgcollapsed"); } return false; }); row.appendChild(td); //------------------------- var populatesubgrid = function( rd ) { var res,sid,dp; sid = $(rd).attr("id"); dp = {id:sid, nd_: (new Date().getTime())}; if(!ts.p.subGridModel[0]) { return false; } if(ts.p.subGridModel[0].params) { for(var j=0; j < ts.p.subGridModel[0].params.length; j++) { for(var i=0; i"+sgmap.row, sjxml).each( function(){ trdiv = document.createElement("div"); trdiv.className="rowdiv"; if(sgmap.repeatitems === true) { $(sgmap.cell,this).each( function(i) { subGridCell(trdiv, this.textContent || this.text || ' ',i); }); } else { var f = ts.p.subGridModel[0].mapping; if (f) { for (i=0;i