jqueryEasyui 之滚动

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=$("
"+"
"+"
"+"
"+"
"+"
"+"
"+"
"+"
"+"
"+""+"
"+"
"+"
"+"
"+"
"+"
"+"
"+"
"+""+"
"+"
"+"
"+"
").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")}}; };

你可能感兴趣的:(jqueryEasyui 之滚动)