一棵小树

Posted 之广

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了一棵小树相关的知识,希望对你有一定的参考价值。

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="zTreeDemo.aspx.cs" Inherits="Log.zTreeDemo" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <link href="Content/zTree/v3/css/zTreeStyle/zTreeStyle.css" rel="stylesheet" />
    <script src="Content/jquery/1.9.1/jquery.min.js"></script>
    <script src="Content/zTree/v3/js/jquery.ztree.all-3.5.min.js"></script>
    <script type="text/javascript">
        //http://www.treejs.cn
        //pIdKey的值如果不设置(pid),默认为pId(上过当)
        var setting = {
            data: {
                simpleData: {
                    enable: true,
                    idKey: "id",
                    pIdKey: "pid",
                    rootPId: 0
                }
            }
        };
        var treeNodes = [
           { id: 1, pid: 0, name: "View1" },
           { id: 11, pid: 1, name: "View2" },
           { id: 12, pid: 1, name: "View3" },
           { id: 111, pid: 11, name: "View4" },
           { id: 1112, pid: 111, name: "View4" }
        ];

        $(document).ready(function () {
            var t = $("#tree");
            t = $.fn.zTree.init(t, setting, treeNodes);
            //zTree = $(".ztree").zTree(setting, treeNodes);
        });


    </script>

    <%--
    var setting = {};

    var zNodes = [
        {
            name: "父节点1 - 展开", open: true,
            children: [
                {
                    name: "父节点11 - 折叠",
                    children: [
                        { name: "叶子节点111" },
                        { name: "叶子节点112" },
                        { name: "叶子节点113" },
                        { name: "叶子节点114" }
                    ]
                },
                {
                    name: "父节点12 - 折叠",
                    children: [
                        { name: "叶子节点121" },
                        { name: "叶子节点122" },
                        { name: "叶子节点123" },
                        { name: "叶子节点124" }
                    ]
                },
                { name: "父节点13 - 没有子节点", isParent: true }
            ]
        },
        {
            name: "父节点2 - 折叠",
            children: [
                {
                    name: "父节点21 - 展开", open: true,
                    children: [
                        { name: "叶子节点211" },
                        { name: "叶子节点212" },
                        { name: "叶子节点213" },
                        { name: "叶子节点214" }
                    ]
                },
                {
                    name: "父节点22 - 折叠",
                    children: [
                        { name: "叶子节点221" },
                        { name: "叶子节点222" },
                        { name: "叶子节点223" },
                        { name: "叶子节点224" }
                    ]
                },
                {
                    name: "父节点23 - 折叠",
                    children: [
                        { name: "叶子节点231" },
                        { name: "叶子节点232" },
                        { name: "叶子节点233" },
                        { name: "叶子节点234" }
                    ]
                }
            ]
        },
        { name: "父节点3 - 没有子节点", isParent: true }

    ];

    $(document).ready(function () {
        $.fn.zTree.init($("#tree"), setting, zNodes);
    });
    //
	--%>
</head>
<body>
    <table>
        <tr>
            <td>
                <ul id="tree" class="ztree" style="width: 260px; overflow: auto;"></ul>
            </td>
        </tr>
    </table>
</body>
</html>

 

以上是关于一棵小树的主要内容,如果未能解决你的问题,请参考以下文章

「题解」树套树 tree

韭菜越割长得越好的道理

最小生成树

POJ 1741 Tree

Educational Codeforces Round 17F Tree nesting

赛道修建