基于JQuery的表格树插件,按 data-id和data-pid计算布局,在表格中展现树型结构。
插件包含初始化选项,监听事件和常用方法。
内置样式使用bootstrap3
在线演示
src/bootstrap-treetable.js
<script src="js/bootstrap-treetable.js"></script>
var treetable = $('#treetable').BootstrapTreeTable({ expandlevel: 1, expandAll: false, collapseAll: false, maxResult: '' })
$('#treetable').BootstrapTreeTable().on("show.bs.treetable", function (e, node) { //console.log('show', node); })
$('#treetable').BootstrapTreeTable('searchNodeName', '计算机'); $('#treetable').BootstrapTreeTable('searchNodeId', '337A2575C9404167AFE020D8C27D1C45'); $('#treetable').BootstrapTreeTable('removeById', '337A2575C9404167AFE020D8C27D1C45'); var node = $(this).parents('tr'); $('#treetable').BootstrapTreeTable('removeByNode', node); $('#treetable').BootstrapTreeTable('removeById', '337A2575C9404167AFE020D8C27D1C45'); $('#treetable').BootstrapTreeTable('expendLevel','2'); $('#treetable').BootstrapTreeTable('expendAll'); $('#treetable').BootstrapTreeTable('collapseAll'); $('#treetable').BootstrapTreeTable('destroy'); $('#treetable').BootstrapTreeTable('reset');
$('#treetable').BootstrapTreeTable('getMaxLevel');