为避免重复造轮子,今天简单看了下将jQuery的TreeGrid,现在将其记录如下,希望能够对大家有所帮助。
插件下载地址:http://plugins.jquery.com/treegrid/
TreeGrid特点
在HTML页面中的table元素中创建TreeGrid
简单灵活的javascript实现
兼容bootstrap2和3
能够保存树的状态
TreeGrid用法
第一步:初始化插件
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery.treegrid.js"></script>
<link rel="stylesheet" href="css/jquery.treegrid.css">
<script type="text/javascript">
$('.tree').treegrid();
</script>
第二步:创建表
<table class="tree">
<tr class="treegrid-1">
<td>Root node</td><td>Additional info</td>
</tr>
<tr class="treegrid-2 treegrid-parent-1">
<td>Node 1-1</td><td>Additional info</td>
</tr>
<tr class="treegrid-3 treegrid-parent-1">
<td>Node 1-2</td><td>Additional info</td>
</tr>
<tr class="treegrid-4 treegrid-parent-3">
<td>Node 1-2-1</td><td>Additional info</td>
</tr>
</table>