zoukankan      html  css  js  c++  java
  • [jquery] jQuery jsTree V3.2.1 基础Demo

    引入对应的文件:

    <link rel="stylesheet" href="../dist/themes/default/style.min.css" />
    	<script src="../dist/jquery-2.1.4.min.js"></script>
    	<script src="../dist/jstree.min.js"></script>
    

     

    
                    $("#deptIdModify").jstree({
    
                        "core" : {
                            'multiple':false,//单选,true 为多选
                            "data": {
                                "url" :"../common/getSelectByCodeId2?codeId=PSB",
                                'dataType':'json',
                                'data' : function (node) {
                                    return { 'id' : node.id};
                                }
                            }
                        },
                        "plugins" : [ "wholerow", "checkbox" ]
                    });
    deptIdModify 可以为:

    div,ul其他没有试过。

    使tree节点选中..
    $("#deptIdModify").jstree(true).check_node(data.formData.deptCode);

     但是上面的选择有一个问题,第一次打开页面无法选中,修改后如下:

    $("#deptIdModify").jstree({
    
                        "core" : {
                            'multiple':false,
                            "data": {
                                "url" :"../common/getSelectByCodeId2?codeId=PSB",
                                'dataType':'json',
                                'data' : function (node) {
                                    return { 'id' : node.id};
                                }
                            }
                        },
                        "plugins" : [ "wholerow", "checkbox" ]
                    }).bind("loaded.jstree",function(){
                        var node = data.formData.deptCode;
                        $("#deptIdModify").jstree("check_node",node);
                    });

    取值:

    var deptIds=$("#deptIdModify").jstree(true).get_selected();

    其他知API,详细配置信息 可访问官网:

     jstree 官网:https://www.jstree.com/

    
    
    
  • 相关阅读:
    springboot1.x+dubbo案例
    dubbo相关的博文
    druid监控配置
    Tomcat启动报错整理
    Hibernate @OneToMany等注解设置查询过滤条件等
    异常处理
    复杂的xml转化为java实体
    简单Java类与XML之间的转换
    mysql errno 150
    JdbcTemplate进行查询
  • 原文地址:https://www.cnblogs.com/lonelywolfmoutain/p/5542681.html
Copyright © 2011-2022 走看看