zoukankan      html  css  js  c++  java
  • jstree使用示例代码

    首先定义一个展示树的div
    <div id="twDept" class="tree-demo"></div>
     
      //初始化树
            function initTree() {
                $('#twDept').jstree({
                    "core": {
                        "themes": {
                            "responsive": false
                        },
                        'check_callback': true,
                        'data': function (obj, callback) {
                            report.DataGet('查询1级部门的接口路径', null, function (data) {
                                if (data) {
                                    callback.call(this, data);
                                }
                            }, null, 'json');
                        }
                    },
                    "types": {
                        "default": {
                            "icon": "fa fa-folder icon-state-warning icon-lg"
                        },
                        "file": {
                            "icon": "fa fa-file icon-state-warning icon-lg"
                        }
                    },
                    "plugins": ["types", "checkbox"],
                    "checkbox": {
                        "keep_selected_style": false,//是否默认选中
                        "three_state": false//父子级别级联选择
                    }
                });
                $('#twDept').on("loaded.jstree", function (e, data) {
                    var root = e.target.firstChild.firstChild;
                    data.instance.open_node(root);
                    _inst = data.instance;
                });
                $('#twDept').on("open_node.jstree", function (e, data) {
                    var inst = data.instance;
                    var selectedNode = inst.get_node(data.node);
                    var firChild = $('#twDept').jstree("get_node", inst.get_children_dom(selectedNode)[0].id);
                    if (firChild.text == "" && selectedNode.id != e.target.firstChild.firstChild.id) {
                        selectedNode.children = [];
                        report.DataGet('查询子节点的接口路径'?code=' + selectedNode.li_attr.treeDeptCode, null, function (data) {
                            if (data) {
                                $.each(data, function (i, item) {
                                    inst.create_node(selectedNode, item, "last");
                                })
                            }
                        }, null, 'json');
                    }
                });
                //end new
            }
  • 相关阅读:
    字符串语法
    组合数
    并查集
    Java Collection HashMap源码分析
    Java 虚拟机 ClassLoader
    Java 多线程 Future
    Java 虚拟机 GC机制
    Java 基础 原生类型
    Java 多线程 死锁deadlock产生原因+避免方法
    Java 基础 基本类型vs引用类型,传值vs传引用
  • 原文地址:https://www.cnblogs.com/nayilvyangguang/p/9981518.html
Copyright © 2011-2022 走看看