jQuery MiniUI

 找回密码
 立即注册
查看: 2366|回复: 4
打印 上一主题 下一主题

Tree 的expandLevel和collapseLevel怎么使用疑问? [复制链接]

Rank: 2

跳转到指定楼层
楼主
发表于 2014-12-5 10:40:56 |只看该作者 |倒序浏览
对树进行收缩,但不想全部收缩,只想显示一级和二级目录,剩下都不显示
tree.collapseLevel(2)没有反应,这个函数如何使用?此功能如何实现?


Rank: 8Rank: 8

沙发
发表于 2014-12-5 11:54:54 |只看该作者
2对应第三级,collpaseLevel(1)看看

Rank: 3Rank: 3

板凳
发表于 2015-10-15 16:22:14 |只看该作者
felt 发表于 2014-12-5 11:54
2对应第三级,collpaseLevel(1)看看

        tree.expandLevel(1);我也试了一下,没有效果

Rank: 3Rank: 3

地板
发表于 2015-10-15 16:23:05 |只看该作者
焰尾迭 发表于 2015-10-15 16:22
tree.expandLevel(1);我也试了一下,没有效果

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>折叠、展开节点</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" /><link href="../demo.css" rel="stylesheet" type="text/css" />

   
    <script src="../../scripts/boot.js" type="text/javascript"></script>
   
   

</head>
<body>
    <h1>折叠、展开节点</h1>      

   
    <input type="button" value="展开所有" onclick="expandAll()"/>
    <input type="button" value="折叠所有" onclick="collapseAll()"/><br />
   
    <input type="button" value="展开第一级" onclick="expandLevel()"/>
  <input type="button" value="展开第二级" onclick="expandLevel2()"/>
    <input type="button" value="折叠第一级" onclick="collapseLevel()"/><br />
   
    <input type="button" value="展开选中节点" onclick="expandNode()"/>
    <input type="button" value="折叠选中节点" onclick="collapseNode()"/><br />

    <input type="button" value="展开节点路径" onclick="expandPath()"/>
    <input type="button" value="折叠节点路径" onclick="collapsePath()"/>
   
    <ul id="tree1" class="mini-tree"  style="width:200px;padding:5px;"
        showTreeIcon="true" textField="text" idField="id"
        
        >        
    </ul>

   
        
    <script type="text/javascript">
        var data=[
        {id: "base", text: "Base",
                children: [
                        {id: "ajax", text: "Ajax"},
                        {id: "json", text: "JSON"},
                        {id: "date", text: "Date"},
                        {id: "control", text: "Control"},
                        {id: "messagebox", text: "MessageBox"},
                        {id: "window", text: "Window"}
                ]
        },
        {id: "forms", text: "Forms",
                children: [
                        {id: "button", text: "Button"},
                        {id: "listbox", text: "ListBox"},
                        {id: "checkboxlist", text: "CheckBoxList"},
                        {id: "radiolist", text: "RadioList"},
                        {id: "calendar", text: "Calendar"},
                        {id: "textbox", text: "TextBox"},
                        {id: "password", text: "Password"},
                        {id: "textarea", text: "TextArea"},
                        {id: "combobox", text: "ComboBox"},
                        {id: "datepicker", text: "DatePicker"},
                        {id: "spinner", text: "Spinner"},
                        {id: "treeselect", text: "TreeSelect"},
                        {id: "fileupload", text: "FileUpload"}
                ]
        },
        {id: "lists", text: "Lists",
                children: [
                        {id: "datagrid", text: "DataGrid"},                       
                        {id: "tree", text: "Tree"},
                        {id: "treegrid", text: "TreeGrid ",children: [
                                {id: "datagrid", text: "DataGrid"}
                        ]}
                ]
        },
        {id: "layouts", text: "Layouts",
                children: [
                        {id: "panel", text: "Panel"},
                        {id: "splitter", text: "Splitter"},
                        {id: "layout", text: "Layout "}
                ]
        },
        {id: "navigations", text: "Navigations",
                children: [
                        {id: "pager", text: "Pager"},
                        {id: "tabs", text: "Tabs"},
                        {id: "outlookbar", text: "OutlookBar"},
                        {id: "menu", text: "Menu"}
                ]
        }
];
      $(function(){
        mini.parse();
            var tree = mini.get("tree1");
      tree.loadData(data);
      });

      
        function collapseAll() {
            var tree = mini.get("tree1");
            tree.collapseAll();
        }
        function expandAll() {
            var tree = mini.get("tree1");
            tree.expandAll();
        }
        function collapseLevel() {
            var tree = mini.get("tree1");
            tree.collapseLevel(0);
        }
        function expandLevel() {
            var tree = mini.get("tree1");
            tree.expandLevel(0);
        }
        function expandLevel2(){
               var tree = mini.get("tree1");
              tree.expandLevel(1);
  
        }
        function collapseNode() {
            var tree = mini.get("tree1");
            var node = tree.getSelectedNode();
            if (node) {
                tree.collapseNode(node);
            }
        }
        function expandNode() {
            var tree = mini.get("tree1");
            var node = tree.getSelectedNode();
            if (node) {
                tree.expandNode(node);
            }
        }

        function collapsePath() {
            var tree = mini.get("tree1");                        
            tree.collapsePath("datagrid");
        }
        function expandPath() {
            var tree = mini.get("tree1");
            tree.selectNode("datagrid");
            tree.expandPath("datagrid");
        }
    </script>

    <div class="description">
        <h3>Description</h3>
        <p>            
        </p>
    </div>
</body>
</html>

Rank: 8Rank: 8

5#
发表于 2015-10-15 16:35:11 |只看该作者
焰尾迭 发表于 2015-10-15 16:23
折叠、展开节点
   

expandLevel(1),展开第二级的节点,请展开lists那个节点看里面的第二级有没有展开

Archiver|普加软件

GMT+8, 2024-10-7 14:34 , Processed in 1.038541 second(s), 10 queries .

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部