合规国际互联网加速 OSASE为企业客户提供高速稳定SD-WAN国际加速解决方案。 广告
## 代码 ``` <!doctype html> <html> <head> <meta charset="utf-8"> <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdn.bootcss.com/jquery/1.11.3/jquery.js"></script> </head> <body> <form class="js-ajax-form" action="{:url('rbac/authorizePost')}" method="post"> <div class="table_full"> <table class="table table-bordered" id="authrule-tree"> <tbody> {$category} </tbody> </table> </div> <div class="form-actions"> <input type="hidden" name="roleId" value="{$roleId}"/> <button class="btn btn-primary js-ajax-submit" type="submit">保存</button> </div> </form> <script src="/static/js/treeTable/treeTable.js"></script> <link rel="stylesheet" href="/static/js/treeTable/treeTable.css"> <script type="text/javascript"> //treeeTable初始化 $(function () { $("#authrule-tree").treeTable({ indent: 20 }); }) //选择 function checknode(obj) { var chk = $("input[type='checkbox']"); var count = chk.length; var num = chk.index(obj); var level_top = level_bottom = chk.eq(num).attr('level'); for (var i = num; i >= 0; i--) { var le = chk.eq(i).attr('level'); if (le < level_top) { chk.eq(i).prop("checked", true); var level_top = level_top - 1; } } for (var j = num + 1; j < count; j++) { var le = chk.eq(j).attr('level'); if (chk.eq(num).prop("checked")) { if (le > level_bottom) { chk.eq(j).prop("checked", true); } else if (le == level_bottom) { break; } } else { if (le > level_bottom) { chk.eq(j).prop("checked", false); } else if (le == level_bottom) { break; } } } } </script> </body> </html> ``` 而如果运用的是`thinkcmf`的wind.js话,加载CSS和JS,必须这样用 ``` $(function () { Wind.css('treeTable'); Wind.use('treeTable', function () { $("#authrule-tree").treeTable({ indent: 20 }); }); }); ```