<bdo id='sV82p'></bdo><ul id='sV82p'></ul>

    1. <i id='sV82p'><tr id='sV82p'><dt id='sV82p'><q id='sV82p'><span id='sV82p'><b id='sV82p'><form id='sV82p'><ins id='sV82p'></ins><ul id='sV82p'></ul><sub id='sV82p'></sub></form><legend id='sV82p'></legend><bdo id='sV82p'><pre id='sV82p'><center id='sV82p'></center></pre></bdo></b><th id='sV82p'></th></span></q></dt></tr></i><div id='sV82p'><tfoot id='sV82p'></tfoot><dl id='sV82p'><fieldset id='sV82p'></fieldset></dl></div>

      1. <tfoot id='sV82p'></tfoot>
      2. <legend id='sV82p'><style id='sV82p'><dir id='sV82p'><q id='sV82p'></q></dir></style></legend>

        <small id='sV82p'></small><noframes id='sV82p'>

        Layui treetable复选框联动解决方案

        我们都知道layui treetable.js没有checked做联动。我们要实现Layui treetable复选框联动要怎么操作呢?实现的最终效果如下: 1. 在当前HTML文档checked监听函数中增加以下代码: //联动 table.on('checkbox(quan_list)', function(obj){ //console.log(obj);

        <small id='a9T8H'></small><noframes id='a9T8H'>

          <tbody id='a9T8H'></tbody>

                • <bdo id='a9T8H'></bdo><ul id='a9T8H'></ul>
                  <i id='a9T8H'><tr id='a9T8H'><dt id='a9T8H'><q id='a9T8H'><span id='a9T8H'><b id='a9T8H'><form id='a9T8H'><ins id='a9T8H'></ins><ul id='a9T8H'></ul><sub id='a9T8H'></sub></form><legend id='a9T8H'></legend><bdo id='a9T8H'><pre id='a9T8H'><center id='a9T8H'></center></pre></bdo></b><th id='a9T8H'></th></span></q></dt></tr></i><div id='a9T8H'><tfoot id='a9T8H'></tfoot><dl id='a9T8H'><fieldset id='a9T8H'></fieldset></dl></div>
                  <tfoot id='a9T8H'></tfoot>
                  <legend id='a9T8H'><style id='a9T8H'><dir id='a9T8H'><q id='a9T8H'></q></dir></style></legend>

                  我们都知道layui treetable.js没有checked做联动。我们要实现Layui treetable复选框联动要怎么操作呢?实现的最终效果如下:

                  1. 在当前HTML文档checked监听函数中增加以下代码:

                          //联动
                          table.on('checkbox(quan_list)', function(obj){
                              //console.log(obj);
                              //当前id
                              var id = obj.data.id;
                              var status = obj.checked;
                              //所有子类选中
                              children_check(id,status);
                              //所有父类选中
                              parent_check(id,status);
                          });
                  2. 当前HTML文档增加两个自定义函数(名字可以随便起)
                  /**
                   * 递归
                   * 当前权限下所有的子权限
                   * @param id 当前权限id
                   * @param status  checked 状态
                   */
                  function  children_check(id,status){
                  	//所有子类
                  	var children_list = $('.layui-table').find('span[lay-tpid='+id+']');
                  	for (var i=0;i<children_list.length;i++){
                  		var this_id = $(children_list[i]).attr('lay-tid');
                  		if($('.layui-table').find('span[lay-tpid='+this_id+']').length > 0){
                  			children_check(this_id,status);
                  		}
                  	}
                  	children_list.parents('td').prev().find('input').next().toggleClass("layui-form-checked");;
                  	children_list.parents('td').prev().find('input').prop('checked', status);
                  }
                   
                   
                  /**
                   * 递归
                   * 当前权限下所有的父元素
                   * @param id 当前权限id
                   * @param status  checked 状态
                   */
                  function  parent_check(id,status){
                  	// 父级
                  	var pid = $('.layui-table').find('span[lay-tid='+id+']').attr('lay-tpid');
                  	//最高层停止
                  	if(pid == 0){
                  		return false;
                  	}
                  	//查看同级元素是否还有选中的
                  	var x_list = $('.layui-table').find('span[lay-tpid='+pid+']');
                  	var check_num = 0
                  	for (var i=0;i < x_list.length;i++){
                  		if($(x_list[i]).parents('td').prev().find('input').prop('checked')){
                  			check_num ++;
                  		}
                  	}
                  	//修改父级状态
                  	var parent_list = $('.layui-table').find('span[lay-tid='+pid+']');
                  	if(status){
                  		//选中样式
                  		if(check_num == 1){
                  			parent_list.parents('td').prev().find('input').next().addClass("layui-form-checked");
                  			parent_list.parents('td').prev().find('input').prop('checked', true);
                  			//查看父级是否还有父级
                  			parent_check(pid,status);
                  		}
                  	}else{
                  		if(check_num == 0) {
                  			parent_list.parents('td').prev().find('input').next().removeClass("layui-form-checked");
                  			parent_list.parents('td').prev().find('input').prop('checked', false);
                  			//查看父级是否还有父级
                  			parent_check(pid,status);
                  		}
                  	}
                   
                  }
                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  按钮代码如下: {field: 'state', title: '状态', width: 85, templet: function (data) { if (data.state == 0) { return 'div input type="checkbox" checked="" name="codeSwitch" lay-skin="switch" id="open" lay-filter="switchTest" switchId=' + data
                  核心方法 var index = layer.open({ type : 2, title : title, maxmin : true, offset: '100px', area : [ '600px', '500px' ], content : prefix + url// iframe的url }); layer.full(index); //最小化 type - 基本层类 类型:Number,默认:0 layer提供了5
                  xm-select是基于layui的多选解决方案,前身formSelects, 由于渲染速度慢, 代码冗余, 被放弃了xm-select使用了新的开发方式, 利用preact进行渲染, 大幅度提高渲染速度, 并且可以灵活拓展。 xm-select: 基于Layui, 下拉选择框的多选解决方案 通过一个简单的小例
                  方法一:jQuery直接取值 var dep = layui.$("#dep").val(); //获取选择框的值 方式二:jQuery直接取值 var dep = xmSelect.get('#dep', true);dep:dep.getValue('valueStr')
                  实现方法使用layui的layui-row类 div class="layui-row" div class="layui-col-xs6 layui-col-sm6 layui-col-md8" input name="verification_code" placeholder="验证码" type="text" class="layui-input input-val" /div div class="layui-col-xs6 layui-col
                  tree的api中,只有tree.setChecked(id, idArr)方法,没有取消勾选的方法。我的需求是:勾选后做判断,如果不符合条件则取消勾

                  <legend id='DVrJm'><style id='DVrJm'><dir id='DVrJm'><q id='DVrJm'></q></dir></style></legend>
                    <tbody id='DVrJm'></tbody>
                          <bdo id='DVrJm'></bdo><ul id='DVrJm'></ul>

                          <small id='DVrJm'></small><noframes id='DVrJm'>

                          <tfoot id='DVrJm'></tfoot>

                            <i id='DVrJm'><tr id='DVrJm'><dt id='DVrJm'><q id='DVrJm'><span id='DVrJm'><b id='DVrJm'><form id='DVrJm'><ins id='DVrJm'></ins><ul id='DVrJm'></ul><sub id='DVrJm'></sub></form><legend id='DVrJm'></legend><bdo id='DVrJm'><pre id='DVrJm'><center id='DVrJm'></center></pre></bdo></b><th id='DVrJm'></th></span></q></dt></tr></i><div id='DVrJm'><tfoot id='DVrJm'></tfoot><dl id='DVrJm'><fieldset id='DVrJm'></fieldset></dl></div>