0

我打算基于jquery的fancytree构建一个组件,但无论我对源数据做什么,文件夹深度都停留在3。是否有一些我无法发现的特殊树选项功能可以防止限制?

提前致谢。凯文

我使用的代码是:

<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  <title>Fancytree - Example</title>
  <script src="../lib/jquery.js" type="text/javascript"></script>
  <script src="../lib/jquery-ui.custom.js" type="text/javascript"></script>
  <link href="../src/skin-xp/ui.fancytree.css" rel="stylesheet" type="text/css">
  <script src="../src/jquery.fancytree.js" type="text/javascript"></script>
  <script type="text/javascript">
   var DT = $.ui.fancytree;
  $.ui.fancytree.debug("Using fancytree " + $.ui.fancytree.version);
  $("#foldertree").fancytree({
   source: {
    url: "data.json"
  },
  lazyload: function(e, data){

    data.result = $.ajax({
      url: "data.json",
      dataType: "json"
    });
   }
  });
// call methods on multiple instances
 $("div:ui-fancytree").fancytree("foo", "after init");
 });
</script>
</head>
<body class="example">
<div id="foldertree" data-source="ajax" class="">
</div>
    <!-- (Irrelevant source removed.) -->
   </body>
</html>

我正在使用的数据样本(我已经更改了很多次)但在下面添加了它以完成。我的观点是,我无法向下钻取超过 3 个文件夹,也无法在任何地方看到任何用于删除文件夹深度的树选项。

[
{"key": "top", "title": "Products", "folder": true, "children": [
    {"key": "under1", "title": "A-E", "folder": true, "children": [
        {"key": "under2", "title": "Parts 0-9", "folder": true ,          "children:": [
                {"key": "under3", "title": "F-M", "folder": true, "children": [
                  {"key": "under4", "title": "F-M", "folder": true, "children": [
                      {"key": "under5", "title": "F-M", "folder": true, "children": [
                          {"key": "under6", "title": "F-M", "folder": true, "children": [

                        ]}
                    ]}
                ]}
            ]}
        ]}
    ]}
]},
{"key": "11", "title": "Samples", "folder": true, "children": [
    {"key": "20", "title": "FG and H", "folder": true, "children": [
        {"key": "30", "title": "Parts 0-9", "folder": true , "children:": [
                {"key": "40", "title": "F-M", "folder": true, "children": [
                    {"key": "42", "title": "Sub-item 1.3.1", "folder": true, "children": [
                        {"key": "43", "title": "Sub-item 1.3.2"}
                    ]},
                    {"key": "44_1", "title": "Sub-item 1.3.2"}
            ]}
        ]}
    ]}
]}
]
4

2 回答 2

0

这是我的数据。我使用了另一个示例中的一个 json 块,并添加了一个额外的文件夹深度,它工作正常,这在某种程度上表明在这种情况下没有限制器。我使用的数据如下。

[
{"title": "Item 1"},
{"title": "Folder 2", "isFolder": true, "key": "folder2", "expand": true,
    "children": [
        {"title": "Sub-item 2.1",
            "children": [
                        {"title": "Sub-item 2.1.1",
                            "children": [
                                        {"title": "Sub-item 2.1.1.1",
                                        "children": [
                                        {"title": "Sub-item 2.1.1.1.1"},
                                        {"title": "Sub-item 2.1.1.2.2"},
                                        {"title": "Sub-item 2.1.1.1.3"},
                                        {"title": "Sub-item 2.1.1.2.4"}
                                    ]

                                        },
                                        {"title": "Sub-item 2.1.2.2"},
                                        {"title": "Sub-item 2.1.1.3"},
                                        {"title": "Sub-item 2.1.2.4"}
                                    ]
                            },
                        {"title": "Sub-item 2.1.2"},
                        {"title": "Sub-item 2.1.3"},
                        {"title": "Sub-item 2.1.4"}
                    ]
            },
        {"title": "Sub-item 2.2"},
        {"title": "Sub-item 2.3 (lazy)", "isLazy": true }
    ]
},
{"title": "Folder 3", "isFolder": true, "key": "folder3",
    "children": [
        {"title": "Sub-item 3.1",
            "children": [
                        {"title": "Sub-item 3.1.1"},
                        {"title": "Sub-item 3.1.2"},
                        {"title": "Sub-item 3.1.3"},
                        {"title": "Sub-item 3.1.4"}
                    ]
            },
        {"title": "Sub-item 3.2"},
        {"title": "Sub-item 3.3"},
        {"title": "Sub-item 3.4"}
    ]
},
{"title": "Lazy Folder 4", "isFolder": true, "isLazy": true, "key": "folder4"},
{"title": "Item 5"}

]

于 2014-01-12T15:27:12.297 回答
0

我也在使用 Fancytree 来加载一个大数据(大约 23 MB),它可以在超过 3 个深度时正常工作。我从您的示例和数据中注意到的一件事是您使用了延迟加载选项,但并非所有数据都具有 isLazy = true。试试看!

此外,您可能还想检查延迟加载数据时树是否抛出错误。在浏览器上按 F12。

于 2015-11-11T23:01:04.247 回答