2012-05-31 15 views
0

我下面http://ludo.cubicphuse.nl/jquery-plugins/treeTable/doc/相當密切,偉大的工程,但似乎我必須已經有一個表中的HTML。我想稍後在程序中構造一個表格,然後通過treeTable運行它以獲取可展開的視圖。當我擺脫了「$(文件)。就緒(函數()」,並定期更換功能,然後調用這個函數構建表後,認爲不工作像它應該。jQuery的treetable中與未確定表

<!DOCTYPE html> 
<html> 
<head> 
    <script type="text/javascript" src="jquery/jquery.js"> </script> 

    <link href="./jquery/jquery.treeTable.css" rel="stylesheet" type="text/css" /> 
    <script type="text/javascript" src="./jquery/jquery.treeTable.js"></script> 
    <script type="text/javascript"> 
    function init() { 
     createTable(); 

     $("#pathTable").treeTable(); 
     } 
    </script> 

    <script type="text/javascript"> 
     function createTable() { 
      document.write('<table id="pathTable"><tbody>'); 
      document.write('<tr id="node-0"><td>node0</td></tr>'); 
      document.write('<tr id="node-1" class="child-of-node-0">'); 
      document.write('<td>node1</td></tr>'); 
      document.write('<tr id="node-2" class="child-of-node-1">'); 
      document.write('<td>node2</td></tr>'); 
      document.write('</tbody></table>');    
     } 
    </script> 
</head> 
<body onload="init()"> 
</body> 
</html> 

回答

0

回答我的問題:

事實證明,文件撰寫()沒有寫入DOM,所以我不能用表再做任何

一個有用的網站here。我發現,解決問題

0

我用這個代碼

//Add format to the table 
$("#FormsAffected-Expandable").treetable({ expandable: true , force :true });  

只有創建表,並添加這個句子中,#名稱控制你的Div的名稱。