dtree.js的使用[轉]

<link rel="StyleSheet" href="css/dtree.css" type="text/css" />  
<script type="text/javascript" src="js/dtree.js"></script>  
必須引用的兩個文件。  

生成樹 節點的代碼:  
      <script type="text/javascript">  
        <!--  
        d = new dTree(’d’);//建立一個樹對象  

        d.add(0,-1,’My example tree’); //建立一個樹對象  
        d.add(1,0,’Node 1’,’example01.html’);  
        d.add(2,0,’Node 2’,’example01.html’);  
        d.add(3,1,’Node 1.1’,’example01.html’);  
        d.add(4,0,’Node 3’,’example01.html’);  
        d.add(5,3,’Node 1.1.1’,’example01.html’);  
        d.add(6,5,’Node 1.1.1.1’,’example01.html’);  
        d.add(7,0,’Node 4’,’example01.html’);  
        d.add(8,1,’Node 1.2’,’example01.html’);  
        d.add(9,0,’My Pictures’,’example01.html’,’Pictures I\’ve taken over the years’,’’,’’,’img/imgfolder.gif’);  
        d.add(10,9,’The trip to Iceland’,’example01.html’,’Pictures of Gullfoss and Geysir’);  
        d.add(11,9,’Mom\’s birthday’,’example01.html’);  
        d.add(12,0,’Recycle Bin’,’example01.html’,’’,’’,’img/trash.gif’);  

        document.write(d);  

        //-->  
    </script>  

d.add(0,-1,’My example tree’);  
這一句爲樹添加了一個根節點,顯示名稱爲’My example tree’ 
javascript

 d.add(1,0,’Node 1’,’example01.html’);  
這一句在樹的根節點下面添加了一個子節點。(d.add()方法的參數具體含義可參見api.html文件)      
css


經常使用的:      
第一個參數,表示當前節點的ID      
第二個參數,表示當前節點的父節點的ID,根節點的值爲 -1      
第三個參數,節點要顯示的文字      
第四個參數,節點的Url      
第五個參數,鼠標移至該節點時節點的Title      
第六個參數,節點的target  
第七個參數,用作節點的圖標,節點沒有指定圖標時使用默認值  
第八個參數,用作節點打開的圖標,節點沒有指定圖標時使用默認值  
第九個參數,判斷節點是否打開  

add()  
向樹裏添加一個節點  
只能在樹被建立以前調用.  
必須 id, pid, name  
參數  
名字    類型    描述  
id    Number    惟一的ID號  
pid    Number    斷定父節點的數字,根節點的值爲 -1  
name    String    節點的文本標籤  
url    String    節點的Url  
title    String    節點的Title  
target    String    節點的target  
icon    String    用作節點的圖標,節點沒有指定圖標時使用默認值  
iconOpen    String    用作節點打開的圖標,節點沒有指定圖標時使用默認值  
open    Boolean    判斷節點是否打開  
例子  
mytree.add(1, 0, ’My node’, ’node.html’, ’node title’, ’mainframe’, ’img/musicfolder.gif’);  

openAll()  
打開全部節點  
可在樹被建立之前或之後調用.  
例子  
mytree.openAll();  

closeAll()  
關閉全部節點  

可在樹被建立之前或之後調用.  
例子  
mytree.closeAll();  

openTo()  
Opens the tree to a certain node and can also select the node.  


只能在樹被建立之後調用..  
參數  
名字    類型    描述  
id    Number    節點惟一的ID號  
select    Boolean    判斷節點是否被選擇  
例子  
mytree.openTo(4, true);  

配置  
變量    類型    默認值    描述  
target    String    true    全部節點的target  
folderLinks    Boolean    true    文件夾可連接  
useSelection    Boolean    true    節點可被選擇(高亮)  
useCookies    Boolean    true    樹能夠使用cookies記住狀態  
useLines    Boolean    true    建立帶線的樹  
useIcons    Boolean    true    建立帶有圖標的樹  
useStatusText    Boolean    false    用節點名替代顯示在狀態欄的節點url  
closeSameLevel    Boolean    false    只有一個有父級的節點能夠被展開,當這個函數可用時openAll() 和 closeAll() 函數將不可用  
inOrder    Boolean    false    若是父級節點老是添加在子級節點以前,使用這個參數能夠加速菜單顯示.  
例子  
mytree.config.target = "mytarget";  


html

相關文章
相關標籤/搜索