1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > layui table设置表格单元格换行 固定列高度改变

layui table设置表格单元格换行 固定列高度改变

时间:2019-07-23 18:49:48

相关推荐

layui table设置表格单元格换行 固定列高度改变

layui table设置表格单元格换行

css

/** 控制表格单元格换行 **/.layui-table-cell {height: auto;word-break: normal;display: block;white-space: pre-wrap;word-wrap: break-word;overflow: hidden;}

js

layui.use('table', function(){var table = layui.table;table.render({done: function(res, curr, count){var tableView = this.elem.next();//控制将表格的列拉伸时,固定列的也会同时将高度改变var bodyTrList = $(".layui-table-main tbody tr");for (var i = 0; i < bodyTrList.length; i++) {var trEle = bodyTrList[i];var dataIndex = trEle.getAttribute("data-index");var offsetHeight = trEle.offsetHeight;$("div[lay-id='initTable'] .layui-table-fixed tr[data-index='" + dataIndex + "']").css({height: offsetHeight + "px"});}$(".layui-table-body tbody tr").resize(function (e) {var dataIndex = e.currentTarget.getAttribute("data-index");var offsetHeight = e.currentTarget.offsetHeight;$("div[lay-id='initTable'] .layui-table-fixed tr[data-index='" + dataIndex + "']").css({height: offsetHeight + "px"});})$("div[lay-id='initTable'] .layui-table-header:first tr").resize(function (e) {var dataIndex = $(this).index();var offsetHeight = this.offsetHeight;$("div[lay-id='initTable'] .layui-table-fixed thead tr").eq(dataIndex).css({height: offsetHeight + "px"});})}});});

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。