layui表格之树形表格
<table id="demoTreeTable1" style="background-color: #00265f;"></table>
function tableFc(data){
layui.config({
base:'./'
}).extend({
treeTable: 'treeTable/treeTable'
}).use(['layer', 'util', 'treeTable'], function () {
var $ = layui.jquery;
var layer = layui.layer;
var util = layui.util;
var treeTable = layui.treeTable;
var insTb = treeTable.render({
elem: '#demoTreeTable1',
url:此处根据自己实际情况写地址,
parseData: function (res) {
return {
"code": 0,
"msg": res.message,
"count": res.data.total,
"data": res.data
};
},
data: data,
tree: {
iconIndex: 0
},
cols: [
{field: '', title: '', width: '26%'},
{field: '', title: '', width: '15%'},
{field: '', title: '', width: '15%'},
{field: '', title: '', width: '10%'},
{field: '', title: '', width: '10%'},
{field: '', title: '', width: '10%'}
],
style: 'margin-top:0;'
});
$('#btnExpandAll').click(function () {
insTb.expandAll();
});
$('#btnFoldAll').click(function () {
insTb.foldAll();
});
$('#btnExpand').click(function () {
insTb.expand('2');
});
$('#btnFold').click(function () {
insTb.fold('2');
});
$('#btnChecked').click(function () {
insTb.expand('1_1_2');
insTb.setChecked(['1_1_2']);
});
$('#btnClearSearch').click(function () {
insTb.clearFilter();
});
$(document).on('mouseenter', '*[lay-tips]', function () {
layer.tips($(this).attr('lay-tips'), this, {tips: [1, '#FF5722'], time: -1});
}).on('mouseleave', '*[lay-tips]', function () {
layer.closeAll('tips');
});
setTimeout(function () {
$('body').children('.page-loading').hide();
$('body').removeClass('page-no-scroll');
}, 150);
});
}
```