如何仅检索父子项并启用展开以获取子项?

时间:2014-09-10 13:07:50

标签: javascript jquery json jstree

为了提高性能,只需加载父节点,然后在用户点击图标时加载子节点,当我不携带子节点时,图标似乎不会展开。任何人都可以帮助我吗?

我的代码在json中返回。下面:

"JsonData": [
  {
    "id": "13",
    "text": "MainBox",
    "parent": "#",
    "state": {
      "opened": false,
      "disabled": false,
      "selected": false
    },
    "children": false,
    "icon": null,
    "li_attr": "{class = 'jstree-leaf' }",
    "a_attr": null
  }
]

修改 我的jquery如下:

root = $('#tree-files').jstree({
        'core': {
            'data': //code before       
        },
        "plugins": ["themes", "json_data", "ui", "contextmenu"]
   });

1 个答案:

答案 0 :(得分:0)

我想出了答案。我希望能为某人提供帮助。

root = $('#tree-files').jstree({
        'core': {
            'data': {
                'url': function (node) {
                    return 'Action/Controller';
                },
                'headers': headers,
                'xhrFields': { withCredentials: true },
                'async': true,
                'data': function (node) {   
                    //handler params here
                    return { 'id': node.id } ;
                },
                success: function (dados) {
                    //code success here
                }
            },
            "check_callback": true,
            "themes": {
                "theme": "default",
                "dots": false,
                "icons": true,
            },
        },
        "plugins": ["themes", "json_data", "ui", "contextmenu", "crrm"]
        });