首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >FancyTree未初始化

FancyTree未初始化
EN

Stack Overflow用户
提问于 2020-11-17 08:19:11
回答 1查看 190关注 0票数 0

我想初始化fancyTree,什么都没发生。数据将通过ajax加载,在chrome的开发工具中,我可以看到ajax响应成功返回,但是fancytree不会呈现响应。上周一切顺利,但这周什么也没发生。我没有改变密码!

在这里,我的javascript代码:

代码语言:javascript
复制
$('#document-tree').fancytree({
            extensions: ["table"],
            source: $.ajax({
                url: '/pdm/document/getDocumentByItem.do?item-number=' + itemNumber
            }),
            debugLevel: 4, // 0:quiet, 1:errors, 2:warnings, 3:infos, 4:debug
            selectMode: 2, // 1:single, 2:multi, 3:multi-hier
            checkbox: true, // Show check boxes
            tooltip: true, // Use title as tooltip (also a callback could be specified)
            titlesTabbable: true, // Add all node titles to TAB chain
            autoScroll: true,
            table: {
                indentation: 20,       // indent 20px per node level
                nodeColumnIdx: 2,      // render the node title into the 2nd column
                checkboxColumnIdx: 0,  // render the checkboxes into the 2nd column
            },
            renderColumns: function(event, data) {
                var node = data.node,
                $tdList = $(node.tr).find(">td");
                // (index #0 is rendered by fancytree by adding the checkbox)
                $tdList.eq(1).text(node.getIndexHier());  //.addClass("alignRight");
                // (index #2 is rendered by fancytree)
                $tdList.eq(3).text(node.data.documentIndex);
                if (node.data.documentCategory != null)
                {
                    var categoryName = node.data.documentCategory.name;
                    if (node.data.documentCategory.singleSubCategory != null)
                    {
                        categoryName += " -> " + node.data.documentCategory.singleSubCategory.name;
                    }
                    $tdList.eq(4).text(categoryName);
                }

                $tdList.eq(5).text(volante.formatDate(node.data.createdAt, 1));

                if (node.isActive())
                {
                    nodeActive(node.data);
                }
                if (node.isSelected())
                {
                    var array = [];
                    array.push(node);
                    nodeSelected(array);
                }
            },
            activate: function (event, data)
            {
                nodeActive(data.node.data);
            },
            select: function(event, data)
            {
                nodeSelected(data.tree.getSelectedNodes());
            },
            init: function (event, data)
            {
                if (data.tree.count() > 0)
                {
                    $('#document-empty').addClass('d-none');
                    $('#document-file-tree').removeClass('d-none');
                }
            }
        });

这里是html的代码

代码语言:javascript
复制
<table id="document-tree">
    <thead>
        <tr>
            <th></th>
            <th>Row</th>
            <th>Document name</th>
            <th>Index</th>
            <th>Category</th>
            <th>Created at</th>
        </tr>
    </thead>
</table>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-12-16 13:44:24

我发现了问题。问题是,json响应包含重复的键,无法处理花式树。

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

https://stackoverflow.com/questions/64871573

复制
相关文章

相似问题

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