javascriptjqueryfancytree

FancyTree not initialize


I want to initialize fancyTree, nothing happend. The data will be loaded via ajax and in developer tools of chrome i can see, that the ajax response returns successfully, but the fancytree will not render the response. Last week it works fine, but this week nothing happends. I have not changed the code!

Here my code of 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');
                }
            }
        });

And here the code of html

<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>

Solution

  • I found the issue. The problem was, that the json response includes duplicate keys, which fancy tree couldn't be handle.