加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
demo2.html 2.76 KB
一键复制 编辑 原始数据 按行查看 历史
温山 提交于 2018-11-06 10:58 . fixed
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<meta name="description" content="">
<meta name="keywords" content="">
<link href="" rel="stylesheet">
<link rel="stylesheet" href="layui/css/layui.css">
</head>
<body style="width: 50%; padding: 10px 10px;">
<div id="demo"></div>
<div id="demo2"></div>
</body>
<script src="layui/layui.js"></script>
<script type="text/javascript">
function del(row) {
alert(row)
}
var layout = [
{ name: '菜单名称', treeNodes: true, headerClass: 'value_col', colClass: 'value_col', style: '' },
{
name: '操作',
headerClass: 'value_col',
colClass: 'value_col',
style: 'width: 20%',
render: function(row) {
return "<a class='layui-btn layui-btn-danger layui-btn-sm' onclick='del(" + row + ")'><i class='layui-icon'>&#xe640;</i> 删除</a>"; //列渲染
}
},
];
layui.use(['form', 'treetable', 'layer'], function() {
var layer = layui.layer, form = layui.form, $ = layui.jquery;
var tree1 = layui.treetable({
elem: '#demo', //传入元素选择器
checkbox: true,
nodes: [{
"id": "1",
"name": "父节点1",
"children": [{
"id": "11",
"name": "子节点11"
},
{
"id": "12",
"name": "子节点12"
}
]
},
{
"id": "2",
"name": "父节点2",
"children": [{
"id": "21",
"name": "子节点21",
"children": [{
"id": "211",
"name": "子节点211"
}]
}]
}
],
layout: layout
});
var tree2 = layui.treeGird({
elem: '#demo2', //传入元素选择器
spreadable: true, //设置是否全展开,默认不展开
checkbox: false,
nodes: [{
"id": "d1",
"name": "父节点1",
"children": [{
"id": "d11",
"name": "子节点11",
"checked": true
}
]
},
{
"id": "d2",
"name": "父节点2",
"children": [{
"id": "d21",
"name": "子节点21",
"children": [{
"id": "d211",
"name": "子节点211"
}]
}]
}
],
layout: layout
});
form.render();
});
</script>
</html>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化