【问题标题】:JSTree - Disable automatic selection of children on loadJSTree - 禁用加载时自动选择子项
【发布时间】:2014-08-26 15:19:39
【问题描述】:

我需要在加载时禁用所有子项的自动选择。如果我将带有 selected 参数的父节点设置为 true,它将选择其所有子节点,但我只想选择父节点。

$('#tree_groups').jstree({
        'plugins': ["wholerow", "checkbox", "types"],
        'core': {
            'data': [{
                "id": "0-14089749041",
                "text": "Sport",
                "state": {
                    "selected": true,
                },
                "children": [{
                "id": "14089749041-14089751330",
                "text": "Pallacanestro",},
                {"id": "14089749041-14089751110",
                "text": "Tennis",},
            ]},
        "types" : {
            "default" : {
                "icon" : "fa fa-group icon-state-warning icon-lg"
            },
            "file" : {
                "icon" : "fa fa-file icon-state-warning icon-lg"
            }
        }
    });

谢谢

【问题讨论】:

  • 请分享您尝试过的任何代码。

标签: javascript php jquery jstree


【解决方案1】:

我自己找到了答案,我刚刚将复选框插件的three_state设置为false。

$('#tree_groups').jstree({
    'plugins': ["wholerow", "checkbox", "types"],
    'core': {
        'data': [{
            "id": "0-14089749041",
            "text": "Sport",
            "state": {
                "selected": true,
            },
            "children": [{
            "id": "14089749041-14089751330",
            "text": "Pallacanestro",},
            {"id": "14089749041-14089751110",
            "text": "Tennis",},
        ]},
    "checkbox" : {
            "three_state" : false,
        },
    "types" : {
        "default" : {
            "icon" : "fa fa-group icon-state-warning icon-lg"
        },
        "file" : {
            "icon" : "fa fa-file icon-state-warning icon-lg"
        }
    }
});

【讨论】:

  • 很好解决。我认为您可以将自己的答案标记为已接受,因为它实际上回答了问题。我还编辑了您的答案并添加了文档链接。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-11-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多