单行固定表头
来源:互联网 发布:mac用手机app 编辑:程序博客网 时间:2024/06/07 05:57
FixTableHeadRow: function(table) {
var table = JsUtil.dom.getObj(table);
if (table) {
JsUtil.fixed._f("_" + table.id, table);
} else {
$(".common_table[display!='none'][name!='noFix'] ").each(function(index, obj) {
JsUtil.fixed._f(index, obj);//不传table对象
});
}
},
_f: function(index, obj) {
if ("_rightTable" == index) {
return;
}
var parent = $(obj).parent();
if (parent.is('DIV')) {
$(parent.children()).each(function(){
if (this.id && new RegExp('^fixTableHeader').test(this.id)) {
$(this).remove();
}
});
parent.scrollLeft = 0 + "px";
var isScroll = JsUtil.dom.isScroll(parent.get(0));
var w = parent.css("width").replace("px", "");
var fixTr = $(obj).find("tr:eq(0)");
var obj1=obj;
if (fixTr.length > 0) {
var th_mTop = fixTr.position().top - parent.position().top - 2.5 + (parent.get(0).scrollTop - 1);
var thDiv = document.getElementById("fixTableHeader" + index);
if (thDiv == null) {
thDiv = document.createElement("div");
$(parent).prepend(thDiv);
$(parent).bind("scroll", {
"tIndex": index
},
JsUtil.fixed.fixTableOnScroll);
}
thDiv.id = "fixTableHeader" + index;
thDiv.style.position = "fixed";
thDiv.style.whiteSpace = "nowrap";
thDiv.style.height = "29px";
thDiv.style.lineHeight = "29px";
thDiv.style.background = "#FFFFFF";
thDiv.style.overflow = "hidden";
/*thDiv.style.marginTop = th_mTop + "px";*/
thDiv.style.marginLeft = "0px";
thDiv.style.width = (isScroll ? (parseFloat(w) - 17) : w) + "px";
thDiv.innerHTML = "";
var thArray = new Array();
$(fixTr).find("th").each(function(index, obj) {
if ($(obj).css("display") !== 'none') {
thArray.push(obj);
}
});
var size = thArray.length;
$(thArray).each(function(index, obj) {
var cW = $(obj).css("width").replace("px","");
var wt2 = (cW == null || cW == undefined || cW == "auto") ? (obj.clientWidth - 4): cW;
var th = document.createElement("div");
th.style.background = "#e0f2fb";
th.style.display = "inline-block";
th.style.height = "100%";
th.style.border = "1px solid #ccc";
th.style.borderRight = "0px";
th.style.verticalAlign = "middle";
th.style.align = "center";
th.style.padding = "0 10px 0 10px";
if($(obj1).hasClass('common_table_nbfl')){
if(index == 0){
th.style.borderLeft = "0";
}
}else{
if (index == size - 1) {
th.style.borderRight = "1px solid #ccc";
}
}
th.style.width = wt2 + "px";
th.innerHTML = obj.innerHTML;
thDiv.appendChild(th);
});
}
}
},
fixTableOnScroll: function(event) {
document.getElementById("fixTableHeader" + event.data.tIndex).scrollLeft = this.scrollLeft;
}
}
只能固定单行th可以
未完待续----------------------------------------------------------------------------------------------------------------
- 单行固定表头
- 表头固定
- 固定表头
- 固定 表头
- 表头固定
- 固定表头
- 固定表头
- 表头固定
- 固定表头的CSS
- 固定表头的DataGrid
- js方式固定表头
- js固定表头补充
- GridView固定表头
- GridView 固定表头
- GridView固定表头
- 固定表头和列
- Excel表头固定
- DataGrid固定表头
- 存入数据库的日期类型(推荐)
- js中split的一点注意事项
- Mysql Innodb死锁解决
- dba 常用查询
- ecshop调用指定栏目下的文章的方法
- 单行固定表头
- krpano全景之内置函数---asyncloop roundval 等(不定期更新)
- LintCode 433: Number of Islands
- C++上机
- js 间隔时间执行函数
- thinkphp核心源码注释|Storage.class.php
- JAX-WS与JAX-RS区别是什么?
- gcc,gdb,makefile
- Adoptable Storage