Because of the project needs, you need to add a tree to the table, using the jquery tree table, the table is beautifully compatible with various frameworks;
Please download the tree table JS files and CSS files, etc., http://ludo.cubicphuse.nl/jquery-treetable/;
Use the CSS file: <link rel= "stylesheet" href= ". /.. /style/jquery.treetable.css ">
<link rel= "stylesheet" href= ". /.. /style/jquery.treetable.theme.default.css ">
Use the JS file: <script src= ". /.. /js/jquery-1.10.1.min.js "></script>
<script src= ". /.. /js/bootstrap-treeview.min.js "></script>
Examples of Use:
<table id= "TableId" > <tr data-tt-id= "1" > <td>Parent</td> </tr> <tr data-tt-id= "2" data-tt-parent-id= "1" > <td>Child</td> </tr></table>
The Data-tt-id is 2 tr through data-tt-parent-id points to 1 nodes, meaning that the second TR is the child node of the first TR;
One line JS done,$ ("#tableId). treetable ({expandable:true});
Hierarchy of complex tables through the background recursive query to find the data list, you can determine whether the node has a parent node to add parent_id to TR, see example:
var Trarr = $ ("#tableId tr");
for (var i = 0; i < trarr.length; i++) {
$ ("#tableId tr:eq (" + i + ")"). attr (
"Data-tt-id", Tabledate[i].orgid);
if (tabledate[i].parentorg! = ") {
$ ("#tableIdtr: eq (" + i + ")"). attr (
"Data-tt-parent-id", tabledate[i].parentorg);
}
}
The tree Table of jquery