如何将检查的节点转换为JSON格式的JSTree?

时间:2018-07-26 06:26:29

标签: json jstree

我正在使用JsTree。下面是我的代码

$("#testing").jstree({
        'plugins': ['search', 'checkbox', 'wholerow'],
        "checkbox": {
            "real_checkboxes" : true,
            "two_state" : true,
            "checked_parent_open" : true,
            "override_ui" : true
        },
        "core" : {
            "multiple" : "on",
            "animation" : 250,
            "data" : result,
            "themes":{
                "icons":false
            }
        }
    })
    .on("changed.jstree", function (e, data) {
        console.log(data.action);

        childrenNodes = data.instance.get_json(data.node.id, { flat: true });

        configToJson(data.action, childrenNodes);
    });

function configToJson(action, childNode) {
        var parentArray = ["func_extensions_job"];
        var childArray = [];

        childrenNodes.forEach(function(childNode) {

        });
    }

我正在使用一种函数来生成所需格式的选定节点。

我所需的格式是

{"func_extensions_job":[{"CodiacSDK.NewModule.dll;extensionCreatePre;":[{"CodiacSDK.NewModule.dll;extensionInquirePost;":[{"CodiacSDK.JavaScriptWrapper.dll;UnitValues::extensionCreatePre;":[]},{"CodiacSDK.JavaScriptWrapper.dll;UnitValues::extensionDeletePre;":[]}]},{"CodiacSDK.NewModule.dll;extensionExecutePost;":[{"CodiacSDK.PythonWrapper.dll;UnitValues::extensionInquirePre;":[]},{"CodiacSDK.PythonWrapper.dll;UnitValues::extensionExecutePre;":[]}]}]},{"CodiacSDK.NewModule.dll;extensionDeletePre;":[{"CodiacSDK.NewModule.dll;extensionInquirePost;":[{"CodiacSDK.JavaScriptWrapper.dll;UnitValues::extensionCreatePre;":[]},{"CodiacSDK.JavaScriptWrapper.dll;UnitValues::extensionDeletePre;":[]}]},{"CodiacSDK.NewModule.dll;extensionExecutePost;":[{"CodiacSDK.PythonWrapper.dll;UnitValues::extensionInquirePre;":[]},{"CodiacSDK.PythonWrapper.dll;UnitValues::extensionExecutePre;":[]}]}]}]};

通过复选框选择/取消选择节点时,我需要运行一个接受节点并准备所需JSON格式的函数。

0 个答案:

没有答案