layui單元格換行 使其能顯示,如果左右列固定,在done回調中使用下方方法
.layui-table-cell {
height: auto;
}
//固定行隨單元格自動調整
function autoFixedHeight(tableElem) {
// 獲取表格div
var $tableView = $(tableElem).next(".layui-table-view");
// 獲取兩側浮動欄
var $fixed = $tableView.find(".layui-table-fixed");
var dataIndex;
var trHeight;
// 遍歷tr 修正浮動欄行高
$tableView.find(".layui-table-main").find("tr").each(function () {
dataIndex = $(this).attr("data-index");
trHeight = $(this).css("height");
$fixed.find("tr[data-index=" + dataIndex + "]").css("height", trHeight);
});
}
//使用
//layui.....
done:function(){
autoFixedHeight(this.elem[0])
}