Jquery插件treeTable:未正确显示

时间:2013-02-20 15:54:04

标签: jquery html-table treetable

我正在使用Jquery插件,treeTable来显示html表。 http://ludo.cubicphuse.nl/jquery-plugins/treeTable/doc/我的代码如下:

<html>
<head>
<link href="treeTable/src/stylesheets/jquery.treeTable.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="treeTable/src/javascripts/jquery.treeTable.js"></script>

<script type="text/javascript" src="treeTable/doc/javascripts/jquery.js"></script>
<script type="text/javascript" src="treeTable/doc/javascripts/jquery.ui.js"></script>

<script>

  $(document).ready(function() {
    $('.type_struct_class').treeTable({
        initialState: 'collapsed'
        });
    $('table#type_struct tbody tr').mousedown(function() {
        $('tr.selected').removeClass('selected'); 
        $(this).addClass('selected');
    });
    $(\"table#type_struct tbody tr span\").mousedown(function() {
        $($(this).parents(\"tr\")[0]).trigger(\"mousedown\");
    });





});
</script>
</head>
<body>

<table class='type_struct_class' id='type_struct'>
  <tr id="node-1">
    <td>Parent</td><td>100</td><td>1000</td>
  </tr>
  <tr id="node-2" class="child-of-node-1">
    <td>Child</td><td>200</td><td>2000</td>
  </tr>
  <tr id="node-3" class="child-of-node-2">
    <td>Child</td><td>300</td><td>3000</td>
  </tr>
</table>

</body>
</html>

我没有看到表格格式化,就像子节点和父节点一样。它在我的Chrome浏览器中显示为普通表格。任何人都可以帮助我出错了吗?

2 个答案:

答案 0 :(得分:1)

我发现jQuery树表和Atlassian产品的集成很困难,并编写了一个兼容的脚本克隆。它还有一些帮助函数来动态生成表:你可以尝试一下:http://culmat.github.io/jsTreeTable/

答案 1 :(得分:0)

试试这个: - http://jsfiddle.net/adiioo7/6mtnL/

$(document).ready(function () {
    $('.type_struct_class').treeTable({
        initialState: 'expanded'
    });
    $('table#type_struct tbody tr').mousedown(function () {
        $('tr.selected').removeClass('selected');
        $(this).addClass('selected');
    });
    $("table#type_struct tbody tr span").mousedown(function () {
        $($(this).parents("tr")[0]).trigger("mousedown");
    });
});