grid

          grid

            BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
            78 Posts :: 0 Stories :: 62 Comments :: 0 Trackbacks
          自定義節點
                                 

          參考示例自定義節點


                                 

          創建代碼         

          <ul id="tree1" class="mini-tree" url="../data/tree.txt" style="width:200px;padding:5px;" 
              showTreeIcon="true" textField="text" idField="id" 
              ondrawnode="onDrawNode" showCheckBox="true">        
          </ul>           

          此時,我們監聽了“drawnode”事件。


                     

          drawnode 事件         

          function onDrawNode(e) {
              var tree = e.sender;
              var node = e.node;
          
              var hasChildren = tree.hasChildren(node);
          
              //所有子節點加上超鏈接
              if (hasChildren == false) {
                  e.nodeHtml = '<a  + node.id + '.html" target="_blank">' + node.text + '</a>';
              }
          
              //父節點高亮顯示;子節點斜線、藍色、下劃線顯示
              if (hasChildren == true) {
                  e.nodeStyle = 'font-weight:bold;';
              } else {
                  e.nodeStyle = "font-style:italic;"; //nodeStyle
                  e.nodeCls = "blueColor";            //nodeCls
              }
          
              //修改默認的父子節點圖標
              if (hasChildren == true) {
                  e.iconCls = "folder";
              } else {
                  e.iconCls = "file";
              }
          
              //父節點的CheckBox全部隱藏
              if (hasChildren == true) {
                  e.showCheckBox = false;
              }
          }
          

             
          Note:   
          1. 文本內容(nodeHtml):所有子節點加上超鏈接   
          2. 節點樣式(nodeStyle/nodeCls):父節點高亮顯示;子節點斜線、藍色、下劃線顯示     
          3. 節點圖片(iconCls):修改默認的父子節點圖標           
          4. 隱藏CheckBox(showCheckBox):父節點的CheckBox全部隱藏           
          5. 開發者可以擴展節點判斷條件,對文本、樣式、圖標、CheckBox等做任意自定義.
          posted on 2012-12-07 16:21 nikofan 閱讀(2780) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 福清市| 台东市| 海丰县| 布尔津县| 当阳市| 云林县| 社会| 襄汾县| 米泉市| 稻城县| 荥阳市| 农安县| 城固县| 那坡县| 林甸县| 安顺市| 珲春市| 罗平县| 赣榆县| 柞水县| 平山县| 缙云县| 乐业县| 县级市| 河北区| 新河县| 阜南县| 准格尔旗| 三明市| 安新县| 宁河县| 星座| 贡山| 华坪县| 拉萨市| 婺源县| 海伦市| 精河县| 合江县| 大庆市| 石棉县|