首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >dynatree js显示树最初已展开

dynatree js显示树最初已展开
EN

Stack Overflow用户
提问于 2013-02-19 19:59:22
回答 1查看 3.7K关注 0票数 1

我已经用dynatree.js创建了一个js树。我有一个很长的等级制度。树在加载时显示已展开。我希望树可以扩展到一个级别。下面是我的代码

代码语言:javascript
复制
<apex:component controller="TreeViewController">
    <apex:attribute name="roleOrUserId" required="true" type="String" assignTo="{!roleOrUserId}" description="Enter Role or User Id to build the hierarchy. Pass null if you are passing JSON data as a parameter" />
    <apex:attribute name="selectable" type="Boolean" assignTo="{!selectable}" description="Do you want nodes to be selectable?" />
    <apex:attribute name="value" type="String" description="IDs of selected Nodes in CSV format" />
    <apex:attribute name="JsonData" type="String" assignTo="{!JsonData}" description="JSON input for the tree component" />
    <apex:inputHidden id="selectedKeys" value="{!value}" />
    <!--<apex:includeScript value="{!URLFOR($Resource.DynaTree, 'jquery/jquery.js' )}" /> -->
    <apex:includescript value="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js"/>
    <apex:includeScript value="{!URLFOR($Resource.DynaTree, 'jquery/jquery-ui.custom.js' )}" />
    <apex:includeScript value="{!URLFOR($Resource.DynaTree, 'jquery/jquery.cookie.js' )}" />
    <apex:includeScript value="{!URLFOR($Resource.DynaTree, 'src/jquery.dynatree.js' )}" />
    <!--<apex:includeScript value="{!$Resource.DynaTreeJs}" /> -->

    <apex:stylesheet value="{!URLFOR($Resource.DynaTree, 'src/skin/ui.dynatree.css')}" />

    <!-- Add code to initialize the tree when the document is loaded: -->
    <script type="text/javascript">
    $.noConflict();
    $(document).ready(function() {
        $(function(){
            // Attach the dynatree widget to an existing <div id="tree"> element
            // and pass the tree options as an argument to the dynatree() function:
            $("#tree").dynatree({
                onActivate: function(node) {
                    // A DynaTreeNode object is passed to the activation handler
                    // Note: we also get this event, if persistence is on, and the page is reloaded.
                    //alert("You activated " + node.data.key);
                },
                persist: false,
                checkbox: true,
                generateIds: false,
                classNames: {
                    checkbox: "dynatree-checkbox",
                    expanded: "dynatree-expanded"
                },
                selectMode: 3,
                children: {!JsonString},
                onSelect: function(select, node) {
                    // Get a list of all selected nodes, and convert to a key array:
                    var selKeys = $.map(node.tree.getSelectedNodes(), function(node){
                        return node.data.key;
                    });
                    jQuery(document.getElementById("{!$Component.selectedKeys}")).val(selKeys.join(", "));

                    // Get a list of all selected TOP nodes
                    var selRootNodes = node.tree.getSelectedNodes(true);
                    // ... and convert to a key array:
                    var selRootKeys = $.map(selRootNodes, function(node){
                        return node.data.key;
                    });
                },

            });

        });

    });
    </script>

    <!-- Add a <div> element where the tree should appear: -->
    <div id="tree"> </div>

</apex:component>

输出

所有子节点都打开到最后一层的树。我只想让第一层开张。怎么做呢?有没有什么背景或其他东西?请帮帮忙

EN

回答 1

Stack Overflow用户

发布于 2013-02-19 20:04:23

一切都在dynatree、docsexamples中。检查minExpandLevel http://wwwendt.de/tech/dynatree/doc/sample-minexpand.html

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14956963

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档