javascript
html 表格 左侧表头,左侧是表头的JS表格控件(自写,网上没有的)
今天,項(xiàng)目中要用到該表格,找了一遍,發(fā)現(xiàn)沒(méi)有合適的,于是自己動(dòng)手豐衣足食。
?
最終呈現(xiàn)效果如上圖,
1、左側(cè)是表頭的表格數(shù)據(jù)展現(xiàn),
2、支持多行,多表頭
3、固定表頭的功能
4、能夠支持標(biāo)題
5、獲取表格中的數(shù)據(jù)
6、支持IE/CHROME
7、 表格能夠自適應(yīng)根據(jù)內(nèi)容行居中
Grid左側(cè)固定測(cè)試var test = new LeftHeadGrid({
id: "leftHeadGrid",
width: 800,
title:"danielinbiti",
perUnitWidth:300,
rowHeads:[{
width:"60",
rowname:[{name:"日期"},{name:"數(shù)值"}]
}],
columnDatas:[{
width:[1,1],
rows:[[10130501,101011],[2,3]]
}]
});
test.RenderTo("testdiv");
LeftHeadGrid.js
var LeftHeadGrid = function(config) {
this.rowHeads = config.rowHeads != null ? config.rowHeads: [];//name
this.columnDatas = config.columnDatas != null ? config.columnDatas: [];
this.width = config.width != null ? config.width: "";
this.id = config.id != null ? config.id: "TreGrid";
this.perUnitWidth = config.perUnitWidth != null ? config.perUnitWidth: 10;
this.innerWidth = 0;
this.innerLWidth = 0;
this.height = 0;
this.title = config.title != null ? config.title: "";
this.noDataStr = config.noDataStr != null ? config.noDataStr: "no data";
}
LeftHeadGrid.prototype.createGrid = function(){
var totalwidth = 0;
var tableHtml = "
for(var i=0;i
var obj = this.rowHeads[i];
var width = obj.width;
totalwidth = totalwidth + parseInt(width);
var rownameobj = obj.rowname;
for(var j=0;j
var nameobj = rownameobj[j];
if(j==rownameobj.length-1){
tableHtml = tableHtml + "
" + nameobj.name + "";}else{
tableHtml = tableHtml + "
" + nameobj.name + "";}
this.height = this.height + 40;
}
}
tableHtml = tableHtml + "
";var headHtml = "
";headHtml = headHtml + tableHtml + "
";this.innerLWidth = totalwidth;
this.innerWidth = this.width-totalwidth-5;
return headHtml;
}
LeftHeadGrid.prototype.RenderTo =function(divId){
//var innerWidth = this.width-100;
var headHtml = this.createGrid();
var html = "
"+ headHtml
+ "
"+ "
"+ "
"+ "
"+ "
"html = "
" + this.title + ""+ html + "
";總結(jié)
以上是生活随笔為你收集整理的html 表格 左侧表头,左侧是表头的JS表格控件(自写,网上没有的)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 微信微粒贷怎么开通,在哪里能找到
- 下一篇: 白条取现审核不通过多久再试