Fancytree 不会折叠已将扩展键设置为 false 的节点

Fancytree doesn't collapse nodes that have expanded key set to false

我有以下 JSON 树结构:

[
    {
        "expanded":"false",
        "key":"_23",
        "title":"Politics",
        "data":{
            "id":"23",
            "name_en":"Politics",
            "description_en":"",
            "seo_title_en":"",
            "seo_description_en":"",
            "name_sr":"Politika",
            "description_sr":"",
            "seo_title_sr":"",
            "seo_description_sr":"",
            "slug_en":"politics",
            "slug_sr":"politika"
        },
        "children":[
            {
                "key":"_24",
                "title":"Domestic politics",
                "data":{
                    "id":"24",
                    "name_en":"Domestic politics",
                    "description_en":"",
                    "seo_title_en":"",
                    "seo_description_en":"",
                    "name_sr":"Doma\u0107a politika",
                    "description_sr":"",
                    "seo_title_sr":"",
                    "seo_description_sr":"",
                    "slug_en":"domestic-politics",
                    "slug_sr":"domaca-politika"
                }
            }
        ]
    },
    {
        "expanded":"false",
        "key":"_21",
        "title":"Sport",
        "data":{
            "id":"21",
            "name_en":"Sport",
            "description_en":"",
            "seo_title_en":"",
            "seo_description_en":"",
            "name_sr":"Sport",
            "description_sr":"",
            "seo_title_sr":"",
            "seo_description_sr":"",
            "slug_en":"sport",
            "slug_sr":"sport"
        },
        "children":[
            {
                "key":"_22",
                "title":"Football",
                "data":{
                    "id":"22",
                    "name_en":"Football",
                    "description_en":"",
                    "seo_title_en":"",
                    "seo_description_en":"",
                    "name_sr":"Fudbla",
                    "description_sr":"",
                    "seo_title_sr":"",
                    "seo_description_sr":"",
                    "slug_en":"football",
                    "slug_sr":"fudbla"
                }
            }
        ]
    }
]

如您所见,第一层的两个节点已扩展设置为 false。但是那些并没有显示在树中倒塌。

我从 AJAX 请求加载树。这是初始化代码:

$("#news-categories-table").fancytree({
    icon: false,
    checkbox: false,
    titlesTabbable: true,
    source: {
        url: SITE_URL + "news_categories/get_tree",
        cache: false
    },
    extensions: ["table", "dnd"],
    table: {
        nodeColumnIdx: 1   // render node expander, icon, and title to this column (default: #0)
    },
    dnd: {
        autoExpandMS: 400,
        draggable: { // modify default jQuery draggable options
            zIndex: 1000,
            scroll: false,
            containment: "parent",
            revert: "invalid"
        },
        preventRecursiveMoves: true, // Prevent dropping nodes on own descendants
        preventVoidMoves: true, // Prevent dropping nodes 'before self', etc.
        dragStart: function(node, data) {
            return true;
        },
        dragEnter: function(node, data) {
            return true;
        },
        dragExpand: function(node, data) {
            return true;
        },
        dragOver: function(node, data) {
            return true;
        },
        dragLeave: function(node, data) {
            return true;
        },
        dragStop: function(node, data) {
            return true;
        },
        dragDrop: function(node, data) {
            data.otherNode.moveTo(node, data.hitMode);
        }
    },
    renderColumns: function(event, data) {
        var node = data.node,
            $tdList = $(node.tr).find(">td");

        // td 1 value is edit icon
        $tdList.eq(0).html(node.data.id);
    }
});

这能以某种方式解决吗?我以前用过 fancytree,旧版本这不是问题。扩展的假节点,在加载树时被折叠。

这里也有截图。

扩展选项需要一个布尔值。尝试传递

"expanded": false,

而不是

"expanded": "false",