jqueryEasyui 之滾動

weixin_33766168發表於2017-09-18

1、實現場景為需要兩個datagruid同步滾動。
擼原始碼發現,其實在生成中,已經向返回資料層丟擲了一個叫做dc的物件,其指向dom層可以直接操作,於是在onAfterRender中可以對dom層進行二次事件繫結。

//生成datagruid
function _684(_685,_686){
function _687(){
var _688=[];
var _689=[];
$(_685).children("thead").each(function(){
var opt=$.parser.parseOptions(this,[{frozen:"boolean"}]);
$(this).find("tr").each(function(){
var cols=[];
$(this).find("th").each(function(){
var th=$(this);
var col=$.extend({},$.parser.parseOptions(this,["id","field","align","halign","order","width",{sortable:"boolean",checkbox:"boolean",resizable:"boolean",fixed:"boolean"},{rowspan:"number",colspan:"number"}]),{title:(th.html()||undefined),hidden:(th.attr("hidden")?true:undefined),formatter:(th.attr("formatter")?eval(th.attr("formatter")):undefined),styler:(th.attr("styler")?eval(th.attr("styler")):undefined),sorter:(th.attr("sorter")?eval(th.attr("sorter")):undefined)});
if(col.width&&String(col.width).indexOf("%")==-1){
col.width=parseInt(col.width);
}
if(th.attr("editor")){
var s=$.trim(th.attr("editor"));
if(s.substr(0,1)=="{"){
col.editor=eval("("+s+")");
}else{
col.editor=s;
}
}
cols.push(col);
});
opt.frozen?_688.push(cols):_689.push(cols);
});
});
return [_688,_689];
};
//生成datagruidView程式碼
var _68a=$("<div class=\"datagrid-wrap\">"+"<div class=\"datagrid-view\">"+"<div class=\"datagrid-view1\">"+"<div class=\"datagrid-header\">"+"<div class=\"datagrid-header-inner\"></div>"+"</div>"+"<div class=\"datagrid-body\">"+"<div class=\"datagrid-body-inner\"></div>"+"</div>"+"<div class=\"datagrid-footer\">"+"<div class=\"datagrid-footer-inner\"></div>"+"</div>"+"</div>"+"<div class=\"datagrid-view2\">"+"<div class=\"datagrid-header\">"+"<div class=\"datagrid-header-inner\"></div>"+"</div>"+"<div class=\"datagrid-body\"></div>"+"<div class=\"datagrid-footer\">"+"<div class=\"datagrid-footer-inner\"></div>"+"</div>"+"</div>"+"</div>"+"</div>").insertAfter(_685);
_68a.panel({doSize:false,cls:"datagrid"});
$(_685).addClass("datagrid-f").hide().appendTo(_68a.children("div.datagrid-view"));
var cc=_687();
var view=_68a.children("div.datagrid-view");
var _68b=view.children("div.datagrid-view1");
var _68c=view.children("div.datagrid-view2");
return {panel:_68a,frozenColumns:cc[0],columns:cc[1],dc:{view:view,view1:_68b,view2:_68c,header1:_68b.children("div.datagrid-header").children("div.datagrid-header-inner"),header2:_68c.children("div.datagrid-header").children("div.datagrid-header-inner"),body1:_68b.children("div.datagrid-body").children("div.datagrid-body-inner"),body2:_68c.children("div.datagrid-body"),footer1:_68b.children("div.datagrid-footer").children("div.datagrid-footer-inner"),footer2:_68c.children("div.datagrid-footer").children("div.datagrid-footer-inner")}};
};

相關文章