在field中添加fixed: true标题和表头合并

//生成年/日表格
function addTable2(data,time,area,titleArray){
for(let e = 0;e<czArray.length;e++){
if(czArray[e].code == area){
area = czArray[e].name;
}
}
let title = area + time + '年'+'统计表';
let colsArr = [[
{title: title, colspan: titleArray.length + 1, align: "center"}
],[
{field:0, 100, title: '日期', align: "center"}
]];
//在field中添加fixed: true标题和表头合并
console.log(titleArray)
for(let i = 1;i<=titleArray.length;i++){
let colsStr1 = {field:i, minWidth:80, title: titleArray[i -1]};
colsArr[1].push(colsStr1);
}
table.render({
elem: '#layTable',
data: data,
height: seeHei,
limit: 100,//显示的数量
cols: colsArr,
done: function (res, curr, count) {
for(let a=count-4;a<=count;a++){
$("tr:nth-child("+ a +")").addClass('colorrow');
}
}
});
//表头居中
let Hwidth0 = $(".layui-table-header").width();
let Hwidth1 = $("tr:first-child span").width();
$("tr:first-child span").css('left',(Hwidth0 - Hwidth1)/2+'px');
}

原文地址:https://www.cnblogs.com/Ao-min/p/13864685.html