All Downloads are FREE. Search and download functionalities are using the official Maven repository.

META-INF.assets.rjzjh.jquery-easyui.plugins.jquery.treegrid.js Maven / Gradle / Ivy

/**
 * jQuery EasyUI 1.4.4
 * 
 * Copyright (c) 2009-2015 www.jeasyui.com. All rights reserved.
 *
 * Licensed under the freeware license: http://www.jeasyui.com/license_freeware.php
 * To use it on other terms please contact us: [email protected]
 *
 */
(function($){
function _1(_2){
var _3=$.data(_2,"treegrid");
var _4=_3.options;
$(_2).datagrid($.extend({},_4,{url:null,data:null,loader:function(){
return false;
},onBeforeLoad:function(){
return false;
},onLoadSuccess:function(){
},onResizeColumn:function(_5,_6){
_16(_2);
_4.onResizeColumn.call(_2,_5,_6);
},onBeforeSortColumn:function(_7,_8){
if(_4.onBeforeSortColumn.call(_2,_7,_8)==false){
return false;
}
},onSortColumn:function(_9,_a){
_4.sortName=_9;
_4.sortOrder=_a;
if(_4.remoteSort){
_15(_2);
}else{
var _b=$(_2).treegrid("getData");
_2f(_2,0,_b);
}
_4.onSortColumn.call(_2,_9,_a);
},onClickCell:function(_c,_d){
_4.onClickCell.call(_2,_d,_37(_2,_c));
},onDblClickCell:function(_e,_f){
_4.onDblClickCell.call(_2,_f,_37(_2,_e));
},onRowContextMenu:function(e,_10){
_4.onContextMenu.call(_2,e,_37(_2,_10));
}}));
var _11=$.data(_2,"datagrid").options;
_4.columns=_11.columns;
_4.frozenColumns=_11.frozenColumns;
_3.dc=$.data(_2,"datagrid").dc;
if(_4.pagination){
var _12=$(_2).datagrid("getPager");
_12.pagination({pageNumber:_4.pageNumber,pageSize:_4.pageSize,pageList:_4.pageList,onSelectPage:function(_13,_14){
_4.pageNumber=_13;
_4.pageSize=_14;
_15(_2);
}});
_4.pageSize=_12.pagination("options").pageSize;
}
};
function _16(_17,_18){
var _19=$.data(_17,"datagrid").options;
var dc=$.data(_17,"datagrid").dc;
if(!dc.body1.is(":empty")&&(!_19.nowrap||_19.autoRowHeight)){
if(_18!=undefined){
var _1a=_1b(_17,_18);
for(var i=0;i<_1a.length;i++){
_1c(_1a[i][_19.idField]);
}
}
}
$(_17).datagrid("fixRowHeight",_18);
function _1c(_1d){
var tr1=_19.finder.getTr(_17,_1d,"body",1);
var tr2=_19.finder.getTr(_17,_1d,"body",2);
tr1.css("height","");
tr2.css("height","");
var _1e=Math.max(tr1.height(),tr2.height());
tr1.css("height",_1e);
tr2.css("height",_1e);
};
};
function _1f(_20){
var dc=$.data(_20,"datagrid").dc;
var _21=$.data(_20,"treegrid").options;
if(!_21.rownumbers){
return;
}
dc.body1.find("div.datagrid-cell-rownumber").each(function(i){
$(this).html(i+1);
});
};
function _22(_23){
return function(e){
$.fn.datagrid.defaults.rowEvents[_23?"mouseover":"mouseout"](e);
var tt=$(e.target);
var fn=_23?"addClass":"removeClass";
if(tt.hasClass("tree-hit")){
tt.hasClass("tree-expanded")?tt[fn]("tree-expanded-hover"):tt[fn]("tree-collapsed-hover");
}
};
};
function _24(e){
var tt=$(e.target);
if(tt.hasClass("tree-hit")){
var tr=tt.closest("tr.datagrid-row");
var _25=tr.closest("div.datagrid-view").children(".datagrid-f")[0];
_26(_25,tr.attr("node-id"));
}else{
$.fn.datagrid.defaults.rowEvents.click(e);
}
};
function _27(_28,_29){
var _2a=$.data(_28,"treegrid").options;
var tr1=_2a.finder.getTr(_28,_29,"body",1);
var tr2=_2a.finder.getTr(_28,_29,"body",2);
var _2b=$(_28).datagrid("getColumnFields",true).length+(_2a.rownumbers?1:0);
var _2c=$(_28).datagrid("getColumnFields",false).length;
_2d(tr1,_2b);
_2d(tr2,_2c);
function _2d(tr,_2e){
$(""+""+"
"+""+"").insertAfter(tr); }; }; function _2f(_30,_31,_32,_33){ var _34=$.data(_30,"treegrid"); var _35=_34.options; var dc=_34.dc; _32=_35.loadFilter.call(_30,_32,_31); var _36=_37(_30,_31); if(_36){ var _38=_35.finder.getTr(_30,_31,"body",1); var _39=_35.finder.getTr(_30,_31,"body",2); var cc1=_38.next("tr.treegrid-tr-tree").children("td").children("div"); var cc2=_39.next("tr.treegrid-tr-tree").children("td").children("div"); if(!_33){ _36.children=[]; } }else{ var cc1=dc.body1; var cc2=dc.body2; if(!_33){ _34.data=[]; } } if(!_33){ cc1.empty(); cc2.empty(); } if(_35.view.onBeforeRender){ _35.view.onBeforeRender.call(_35.view,_30,_31,_32); } _35.view.render.call(_35.view,_30,cc1,true); _35.view.render.call(_35.view,_30,cc2,false); if(_35.showFooter){ _35.view.renderFooter.call(_35.view,_30,dc.footer1,true); _35.view.renderFooter.call(_35.view,_30,dc.footer2,false); } if(_35.view.onAfterRender){ _35.view.onAfterRender.call(_35.view,_30); } if(!_31&&_35.pagination){ var _3a=$.data(_30,"treegrid").total; var _3b=$(_30).datagrid("getPager"); if(_3b.pagination("options").total!=_3a){ _3b.pagination({total:_3a}); } } _16(_30); _1f(_30); $(_30).treegrid("showLines"); $(_30).treegrid("setSelectionState"); $(_30).treegrid("autoSizeColumn"); _35.onLoadSuccess.call(_30,_36,_32); }; function _15(_3c,_3d,_3e,_3f,_40){ var _41=$.data(_3c,"treegrid").options; var _42=$(_3c).datagrid("getPanel").find("div.datagrid-body"); if(_3e){ _41.queryParams=_3e; } var _43=$.extend({},_41.queryParams); if(_41.pagination){ $.extend(_43,{page:_41.pageNumber,rows:_41.pageSize}); } if(_41.sortName){ $.extend(_43,{sort:_41.sortName,order:_41.sortOrder}); } var row=_37(_3c,_3d); if(_41.onBeforeLoad.call(_3c,row,_43)==false){ return; } var _44=_42.find("tr[node-id=\""+_3d+"\"] span.tree-folder"); _44.addClass("tree-loading"); $(_3c).treegrid("loading"); var _45=_41.loader.call(_3c,_43,function(_46){ _44.removeClass("tree-loading"); $(_3c).treegrid("loaded"); _2f(_3c,_3d,_46,_3f); if(_40){ _40(); } },function(){ _44.removeClass("tree-loading"); $(_3c).treegrid("loaded"); _41.onLoadError.apply(_3c,arguments); if(_40){ _40(); } }); if(_45==false){ _44.removeClass("tree-loading"); $(_3c).treegrid("loaded"); } }; function _47(_48){ var _49=_4a(_48); if(_49.length){ return _49[0]; }else{ return null; } }; function _4a(_4b){ return $.data(_4b,"treegrid").data; }; function _4c(_4d,_4e){ var row=_37(_4d,_4e); if(row._parentId){ return _37(_4d,row._parentId); }else{ return null; } }; function _1b(_4f,_50){ var _51=$.data(_4f,"treegrid").options; var _52=$(_4f).datagrid("getPanel").find("div.datagrid-view2 div.datagrid-body"); var _53=[]; if(_50){ _54(_50); }else{ var _55=_4a(_4f); for(var i=0;i<_55.length;i++){ _53.push(_55[i]); _54(_55[i][_51.idField]); } } function _54(_56){ var _57=_37(_4f,_56); if(_57&&_57.children){ for(var i=0,len=_57.children.length;i").insertBefore(_84); if(hit.prev().length){ hit.prev().remove(); } } } _2f(_80,_81.parent,_81.data,true); }; function _85(_86,_87){ var ref=_87.before||_87.after; var _88=$.data(_86,"treegrid").options; var _89=_4c(_86,ref); _7f(_86,{parent:(_89?_89[_88.idField]:null),data:[_87.data]}); var _8a=_89?_89.children:$(_86).treegrid("getRoots"); for(var i=0;i<_8a.length;i++){ if(_8a[i][_88.idField]==ref){ var _8b=_8a[_8a.length-1]; _8a.splice(_87.before?i:(i+1),0,_8b); _8a.splice(_8a.length-1,1); break; } } _8c(true); _8c(false); _1f(_86); $(_86).treegrid("showLines"); function _8c(_8d){ var _8e=_8d?1:2; var tr=_88.finder.getTr(_86,_87.data[_88.idField],"body",_8e); var _8f=tr.closest("table.datagrid-btable"); tr=tr.parent().children(); var _90=_88.finder.getTr(_86,ref,"body",_8e); if(_87.before){ tr.insertBefore(_90); }else{ var sub=_90.next("tr.treegrid-tr-tree"); tr.insertAfter(sub.length?sub:_90); } _8f.remove(); }; }; function _91(_92,_93){ var _94=$.data(_92,"treegrid"); $(_92).datagrid("deleteRow",_93); _1f(_92); _94.total-=1; $(_92).datagrid("getPager").pagination("refresh",{total:_94.total}); $(_92).treegrid("showLines"); }; function _95(_96){ var t=$(_96); var _97=t.treegrid("options"); if(_97.lines){ t.treegrid("getPanel").addClass("tree-lines"); }else{ t.treegrid("getPanel").removeClass("tree-lines"); return; } t.treegrid("getPanel").find("span.tree-indent").removeClass("tree-line tree-join tree-joinbottom"); t.treegrid("getPanel").find("div.datagrid-cell").removeClass("tree-node-last tree-root-first tree-root-one"); var _98=t.treegrid("getRoots"); if(_98.length>1){ _99(_98[0]).addClass("tree-root-first"); }else{ if(_98.length==1){ _99(_98[0]).addClass("tree-root-one"); } } _9a(_98); _9b(_98); function _9a(_9c){ $.map(_9c,function(_9d){ if(_9d.children&&_9d.children.length){ _9a(_9d.children); }else{ var _9e=_99(_9d); _9e.find(".tree-icon").prev().addClass("tree-join"); } }); if(_9c.length){ var _9f=_99(_9c[_9c.length-1]); _9f.addClass("tree-node-last"); _9f.find(".tree-join").removeClass("tree-join").addClass("tree-joinbottom"); } }; function _9b(_a0){ $.map(_a0,function(_a1){ if(_a1.children&&_a1.children.length){ _9b(_a1.children); } }); for(var i=0;i<_a0.length-1;i++){ var _a2=_a0[i]; var _a3=t.treegrid("getLevel",_a2[_97.idField]); var tr=_97.finder.getTr(_96,_a2[_97.idField]); var cc=tr.next().find("tr.datagrid-row td[field=\""+_97.treeField+"\"] div.datagrid-cell"); cc.find("span:eq("+(_a3-1)+")").addClass("tree-line"); } }; function _99(_a4){ var tr=_97.finder.getTr(_96,_a4[_97.idField]); var _a5=tr.find("td[field=\""+_97.treeField+"\"] div.datagrid-cell"); return _a5; }; }; $.fn.treegrid=function(_a6,_a7){ if(typeof _a6=="string"){ var _a8=$.fn.treegrid.methods[_a6]; if(_a8){ return _a8(this,_a7); }else{ return this.datagrid(_a6,_a7); } } _a6=_a6||{}; return this.each(function(){ var _a9=$.data(this,"treegrid"); if(_a9){ $.extend(_a9.options,_a6); }else{ _a9=$.data(this,"treegrid",{options:$.extend({},$.fn.treegrid.defaults,$.fn.treegrid.parseOptions(this),_a6),data:[]}); } _1(this); if(_a9.options.data){ $(this).treegrid("loadData",_a9.options.data); } _15(this); }); }; $.fn.treegrid.methods={options:function(jq){ return $.data(jq[0],"treegrid").options; },resize:function(jq,_aa){ return jq.each(function(){ $(this).datagrid("resize",_aa); }); },fixRowHeight:function(jq,_ab){ return jq.each(function(){ _16(this,_ab); }); },loadData:function(jq,_ac){ return jq.each(function(){ _2f(this,_ac.parent,_ac); }); },load:function(jq,_ad){ return jq.each(function(){ $(this).treegrid("options").pageNumber=1; $(this).treegrid("getPager").pagination({pageNumber:1}); $(this).treegrid("reload",_ad); }); },reload:function(jq,id){ return jq.each(function(){ var _ae=$(this).treegrid("options"); var _af={}; if(typeof id=="object"){ _af=id; }else{ _af=$.extend({},_ae.queryParams); _af.id=id; } if(_af.id){ var _b0=$(this).treegrid("find",_af.id); if(_b0.children){ _b0.children.splice(0,_b0.children.length); } _ae.queryParams=_af; var tr=_ae.finder.getTr(this,_af.id); tr.next("tr.treegrid-tr-tree").remove(); tr.find("span.tree-hit").removeClass("tree-expanded tree-expanded-hover").addClass("tree-collapsed"); _67(this,_af.id); }else{ _15(this,null,_af); } }); },reloadFooter:function(jq,_b1){ return jq.each(function(){ var _b2=$.data(this,"treegrid").options; var dc=$.data(this,"datagrid").dc; if(_b1){ $.data(this,"treegrid").footer=_b1; } if(_b2.showFooter){ _b2.view.renderFooter.call(_b2.view,this,dc.footer1,true); _b2.view.renderFooter.call(_b2.view,this,dc.footer2,false); if(_b2.view.onAfterRender){ _b2.view.onAfterRender.call(_b2.view,this); } $(this).treegrid("fixRowHeight"); } }); },getData:function(jq){ return $.data(jq[0],"treegrid").data; },getFooterRows:function(jq){ return $.data(jq[0],"treegrid").footer; },getRoot:function(jq){ return _47(jq[0]); },getRoots:function(jq){ return _4a(jq[0]); },getParent:function(jq,id){ return _4c(jq[0],id); },getChildren:function(jq,id){ return _1b(jq[0],id); },getLevel:function(jq,id){ return _59(jq[0],id); },find:function(jq,id){ return _37(jq[0],id); },isLeaf:function(jq,id){ var _b3=$.data(jq[0],"treegrid").options; var tr=_b3.finder.getTr(jq[0],id); var hit=tr.find("span.tree-hit"); return hit.length==0; },select:function(jq,id){ return jq.each(function(){ $(this).datagrid("selectRow",id); }); },unselect:function(jq,id){ return jq.each(function(){ $(this).datagrid("unselectRow",id); }); },collapse:function(jq,id){ return jq.each(function(){ _63(this,id); }); },expand:function(jq,id){ return jq.each(function(){ _67(this,id); }); },toggle:function(jq,id){ return jq.each(function(){ _26(this,id); }); },collapseAll:function(jq,id){ return jq.each(function(){ _71(this,id); }); },expandAll:function(jq,id){ return jq.each(function(){ _76(this,id); }); },expandTo:function(jq,id){ return jq.each(function(){ _7b(this,id); }); },append:function(jq,_b4){ return jq.each(function(){ _7f(this,_b4); }); },insert:function(jq,_b5){ return jq.each(function(){ _85(this,_b5); }); },remove:function(jq,id){ return jq.each(function(){ _91(this,id); }); },pop:function(jq,id){ var row=jq.treegrid("find",id); jq.treegrid("remove",id); return row; },refresh:function(jq,id){ return jq.each(function(){ var _b6=$.data(this,"treegrid").options; _b6.view.refreshRow.call(_b6.view,this,id); }); },update:function(jq,_b7){ return jq.each(function(){ var _b8=$.data(this,"treegrid").options; _b8.view.updateRow.call(_b8.view,this,_b7.id,_b7.row); }); },beginEdit:function(jq,id){ return jq.each(function(){ $(this).datagrid("beginEdit",id); $(this).treegrid("fixRowHeight",id); }); },endEdit:function(jq,id){ return jq.each(function(){ $(this).datagrid("endEdit",id); }); },cancelEdit:function(jq,id){ return jq.each(function(){ $(this).datagrid("cancelEdit",id); }); },showLines:function(jq){ return jq.each(function(){ _95(this); }); }}; $.fn.treegrid.parseOptions=function(_b9){ return $.extend({},$.fn.datagrid.parseOptions(_b9),$.parser.parseOptions(_b9,["treeField",{animate:"boolean"}])); }; var _ba=$.extend({},$.fn.datagrid.defaults.view,{render:function(_bb,_bc,_bd){ var _be=$.data(_bb,"treegrid").options; var _bf=$(_bb).datagrid("getColumnFields",_bd); var _c0=$.data(_bb,"datagrid").rowIdPrefix; if(_bd){ if(!(_be.rownumbers||(_be.frozenColumns&&_be.frozenColumns.length))){ return; } } var _c1=this; if(this.treeNodes&&this.treeNodes.length){ var _c2=_c3(_bd,this.treeLevel,this.treeNodes); $(_bc).append(_c2.join("")); } function _c3(_c4,_c5,_c6){ var _c7=$(_bb).treegrid("getParent",_c6[0][_be.idField]); var _c8=(_c7?_c7.children.length:$(_bb).treegrid("getRoots").length)-_c6.length; var _c9=[""]; for(var i=0;i<_c6.length;i++){ var row=_c6[i]; if(row.state!="open"&&row.state!="closed"){ row.state="open"; } var css=_be.rowStyler?_be.rowStyler.call(_bb,row):""; var _ca=""; var _cb=""; if(typeof css=="string"){ _cb=css; }else{ if(css){ _ca=css["class"]||""; _cb=css["style"]||""; } } var cls="class=\"datagrid-row "+(_c8++%2&&_be.striped?"datagrid-row-alt ":" ")+_ca+"\""; var _cc=_cb?"style=\""+_cb+"\"":""; var _cd=_c0+"-"+(_c4?1:2)+"-"+row[_be.idField]; _c9.push(""); _c9=_c9.concat(_c1.renderRow.call(_c1,_bb,_bf,_c4,_c5,row)); _c9.push(""); if(row.children&&row.children.length){ var tt=_c3(_c4,_c5+1,row.children); var v=row.state=="closed"?"none":"block"; _c9.push(""); } } _c9.push("
"); _c9=_c9.concat(tt); _c9.push("
"); return _c9; }; },renderFooter:function(_ce,_cf,_d0){ var _d1=$.data(_ce,"treegrid").options; var _d2=$.data(_ce,"treegrid").footer||[]; var _d3=$(_ce).datagrid("getColumnFields",_d0); var _d4=[""]; for(var i=0;i<_d2.length;i++){ var row=_d2[i]; row[_d1.idField]=row[_d1.idField]||("foot-row-id"+i); _d4.push(""); _d4.push(this.renderRow.call(this,_ce,_d3,_d0,0,row)); _d4.push(""); } _d4.push("
"); $(_cf).html(_d4.join("")); },renderRow:function(_d5,_d6,_d7,_d8,row){ var _d9=$.data(_d5,"treegrid").options; var cc=[]; if(_d7&&_d9.rownumbers){ cc.push("
0
"); } for(var i=0;i<_d6.length;i++){ var _da=_d6[i]; var col=$(_d5).datagrid("getColumnOption",_da); if(col){ var css=col.styler?(col.styler(row[_da],row)||""):""; var _db=""; var _dc=""; if(typeof css=="string"){ _dc=css; }else{ if(cc){ _db=css["class"]||""; _dc=css["style"]||""; } } var cls=_db?"class=\""+_db+"\"":""; var _dd=col.hidden?"style=\"display:none;"+_dc+"\"":(_dc?"style=\""+_dc+"\"":""); cc.push(""); var _dd=""; if(!col.checkbox){ if(col.align){ _dd+="text-align:"+col.align+";"; } if(!_d9.nowrap){ _dd+="white-space:normal;height:auto;"; }else{ if(_d9.autoRowHeight){ _dd+="height:auto;"; } } } cc.push("
"); if(col.checkbox){ if(row.checked){ cc.push(""); }else{ var val=null; if(col.formatter){ val=col.formatter(row[_da],row); }else{ val=row[_da]; } if(_da==_d9.treeField){ for(var j=0;j<_d8;j++){ cc.push(""); } if(row.state=="closed"){ cc.push(""); cc.push(""); }else{ if(row.children&&row.children.length){ cc.push(""); cc.push(""); }else{ cc.push(""); cc.push(""); } } cc.push(""+val+""); }else{ cc.push(val); } } cc.push("
"); cc.push(""); } } return cc.join(""); },refreshRow:function(_de,id){ this.updateRow.call(this,_de,id,{}); },updateRow:function(_df,id,row){ var _e0=$.data(_df,"treegrid").options; var _e1=$(_df).treegrid("find",id); $.extend(_e1,row); var _e2=$(_df).treegrid("getLevel",id)-1; var _e3=_e0.rowStyler?_e0.rowStyler.call(_df,_e1):""; var _e4=$.data(_df,"datagrid").rowIdPrefix; var _e5=_e1[_e0.idField]; function _e6(_e7){ var _e8=$(_df).treegrid("getColumnFields",_e7); var tr=_e0.finder.getTr(_df,id,"body",(_e7?1:2)); var _e9=tr.find("div.datagrid-cell-rownumber").html(); var _ea=tr.find("div.datagrid-cell-check input[type=checkbox]").is(":checked"); tr.html(this.renderRow(_df,_e8,_e7,_e2,_e1)); tr.attr("style",_e3||""); tr.find("div.datagrid-cell-rownumber").html(_e9); if(_ea){ tr.find("div.datagrid-cell-check input[type=checkbox]")._propAttr("checked",true); } if(_e5!=id){ tr.attr("id",_e4+"-"+(_e7?1:2)+"-"+_e5); tr.attr("node-id",_e5); } }; _e6.call(this,true); _e6.call(this,false); $(_df).treegrid("fixRowHeight",id); },deleteRow:function(_eb,id){ var _ec=$.data(_eb,"treegrid").options; var tr=_ec.finder.getTr(_eb,id); tr.next("tr.treegrid-tr-tree").remove(); tr.remove(); var _ed=del(id); if(_ed){ if(_ed.children.length==0){ tr=_ec.finder.getTr(_eb,_ed[_ec.idField]); tr.next("tr.treegrid-tr-tree").remove(); var _ee=tr.children("td[field=\""+_ec.treeField+"\"]").children("div.datagrid-cell"); _ee.find(".tree-icon").removeClass("tree-folder").addClass("tree-file"); _ee.find(".tree-hit").remove(); $("").prependTo(_ee); } } function del(id){ var cc; var _ef=$(_eb).treegrid("getParent",id); if(_ef){ cc=_ef.children; }else{ cc=$(_eb).treegrid("getData"); } for(var i=0;ib?1:-1); }; r=_100(r1[sn],r2[sn])*(so=="asc"?1:-1); if(r!=0){ return r; } } return r; }); for(var i=0;i<_ff.length;i++){ var _101=_ff[i].children; if(_101&&_101.length){ _fe(_101); } } }; },transfer:function(_102,_103,data){ var opts=$.data(_102,"treegrid").options; var rows=[]; for(var i=0;i




© 2015 - 2025 Weber Informatics LLC | Privacy Policy