Tree菜单 复选框选中控制DEMO
java 对应实体类属定义
public class AccoSysmanResource{
/**
* 资源类型
*/
private Integer resourceType;
/**
* 权限名称
*/
private String name;
/**
* 权限描述
*/
private String description;
/**
* 排序
*/
private Integer level;
/**
* 子节点
*/
private List<AccoSysmanResource> subResource;
private Integer pid;
private Integer deleteFlag;
private Integer pMenuId;
private Date createtime;
}
jsp页面循环遍历属性结构代码
<!-- tree_start -->
<div class="col-md-3">
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="sour">
<div class="data-div">
<div class="row tableHeader">
<div class="col-lg-11 col-md-11 col-sm-11 col-xs-11">
<label>
<input name="checkname" type="checkbox" value="0" onclick="checkboxById(this,'biz')"/>菜单 全选
</label>
</div>
</div>
<div class="tablebody">
<div id="collapseSystem" class="collapse in" aria-expanded="true">
<!-- 第一层 start -->
<c:forEach items="${bizList}" var="menu" varStatus="rows">
<div class="row">
<div class="col-lg-11 col-md-11 col-sm-11 col-xs-11 levl3" role="button" >
<c:if test="${empty menu.subResource}" var="biz_not_empty_subResource">
<span class="glyphicon glyphicon-pushpin"></span>
</c:if>
<c:if test="${not biz_not_empty_subResource}">
<i id="down_biz_${rows.index}" class="glyphicon glyphicon-hand-down" style="display: ${rows.index==0 ? 'none':''};"></i>
<i id="up_biz_${rows.index}" class="glyphicon glyphicon-hand-up" style="display: ${rows.index!=0 ? 'none':''};"></i>
</c:if>
<label>
<input name="bizMenuId" type="checkbox" value="${menu.pid}" id="biz_${rows.index}" onclick="checkboxById(this,'biz_${rows.index}_')"/>
</label>
<span role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse_biz_${rows.index}" aria-expanded="true" onclick="dom('biz_${rows.index}')">${menu.name}</span>
</div>
</div>
<!-- 第二层 start -->
<c:if test="${not biz_not_empty_subResource}">
<div id="collapse_biz_${rows.index}" class="${rows.index==0 ? 'collapse in':'collapse'}" aria-expanded="${rows.index==0 ? 'true':'false'}">
<c:forEach items="${menu.subResource}" var="m" varStatus="i">
<div class="row" style="border-top:1px solid #E3E8EE;">
<div class="col-lg-11 col-md-11 col-sm-11 col-xs-11 levl3">
<label>
<input name="bizMenuId" value="${m.pid}" type="checkbox" id="biz_${rows.index}_${i.index}" onclick="checkboxById(this,'biz_${rows.index}_${i.index}_')" />
<span role="button" data-toggle="collapse" data-parent="#accordion" aria-expanded="true" href="#collapse_biz_${rows.index}_${i.index}" >
<c:if test="${empty m.subResource}" var="biz_not_empty_m_subResource">
|--${m.name}
</c:if>
<c:if test="${not biz_not_empty_m_subResource}">
<span class="glyphicon glyphicon-triangle-bottom"></span>${m.name}
</c:if>
</span>
</label>
</div>
</div>
<!-- 第三层start -->
<c:if test="${not biz_not_empty_m_subResource}">
<div id="collapse_biz_${rows.index}_${i.index}" class="collapse in" aria-expanded="true" >
<c:forEach items="${m.subResource}" var="m2" varStatus="i3">
<div class="row" style="border-top:1px solid #E3E8EE;">
<div class="col-lg-11 col-md-11 col-sm-11 col-xs-11 levl3" >
<label>
<input name="bizMenuId" value="${m2.pid}" type="checkbox" id="biz_${rows.index}_${i.index}_${i3.index}" onclick="childCheckboxById(this,'biz_${rows.index}_${i.index}_${i3.index}')" />
<span>|----${m2.name}</span>
</label>
</div>
</div>
</c:forEach>
</div>
</c:if>
<!-- 第三层end -->
</c:forEach>
</div>
</c:if>
<!-- 第二层 end -->
</c:forEach>
<!-- 第一层 end -->
</div>
</div>
</div>
</div>
</div>
</div>
<!-- tree_end -->
js文件(必须先导入Jquery.js 文件)
/** 全选 */
function checkboxAll(obj, cheName) {
if ($(obj).prop("checked")){
$("input[name='" + cheName + "']").prop("checked", true);
} else {
$("input[name='" + cheName + "']").prop("checked", false);
}
}
/**cheId开头的Id全选*/
function checkboxById(obj, cheId){
var parent2=cheId.substr(0,cheId.lastIndexOf('_'));
var parent1=parent2.substr(0,parent2.lastIndexOf('_'));
if ($(obj).prop("checked")){
$("input[id='" + parent1 + "']").prop("checked", true);
$("input[id^='" + cheId + "']").prop("checked", true);
} else {
$("input[id^='" + cheId + "']").prop("checked", false);
var parent3=parent1+"_";
var index=0;
$("input[id^='"+parent3+"']:checked").each(function(){
index++;
});
if(index==0){
$("input[id='" + parent1 + "']").prop("checked", false);
}
}
}
/**三级节点点击触发**/
function childCheckboxById(obj, parentCheId){
var parent2=parentCheId.substr(0,parentCheId.lastIndexOf('_'));
var parent1=parent2.substr(0,parent2.lastIndexOf('_'));
if ($(obj).prop("checked")){
$("input[id='" + parentCheId + "']").prop("checked", true);
$("input[id='" + parent2 + "']").prop("checked", true);
$("input[id='" + parent1 + "']").prop("checked", true);
} else {
$("input[id='" + parentCheId + "']").prop("checked", false);
var parent3=parent2+"_";
var index=0;
$("input[id^='"+parent3+"']:checked").each(function(){
index++;
});
if(index==0){
$("input[id='" + parent2 + "']").prop("checked", false);
}
var parent4=parent1+"_";
var index2=0;
$("input[id^='"+parent4+"']:checked").each(function(){
index2++;
});
if(index2==0){
$("input[id='" + parent1 + "']").prop("checked", false);
}
}
}
Tree菜单 复选框选中控制DEMO的更多相关文章
- 关于textjs的tree带复选框的树
通过查阅一些资料和自己之前了解到的一些相关知识,有时项目中需要用到.话不多说,先看一下效果图: 我写的这人员选择的树,主要是改写了TreePanel,如下代码: ExtendTreePanel.js ...
- jquery复选框 选中事件 及其判断是否被选中
jquery复选框 选中事件 及其判断是否被选中 (2014-07-25 14:03:54) 转载▼ 标签: jquery复选框选中事件 分类: extjs jquery 今天做了 显示和不显示密 ...
- Web前端之复选框选中属性
熟悉web前端开发的人都知道,判断复选框是否选中是经常做的事情,判断的方法很多,但是开发过程中常常忽略了这些方法的兼容性,而是实现效果就好 了.博主之前用户不少方法,经常Google到一些这个不好那个 ...
- Javascript 统计复选框选中个数
var checked = document.getElementsByName("checked_c[]"); var checked_counts = 0; for(var i ...
- JS复选框选中
Web前端之复选框选中属性 熟悉web前端开发的人都知道,判断复选框是否选中是经常做的事情,判断的方法很多,但是开发过程中常常忽略了这些方法的兼容性,而是实现效果就好了.博主之前用户不少方法,经常 ...
- springMvc接收ajax数组参数,以及jquery复选框选中、反选、全选、全不选
一.复选框选中.反选.全选.全不选 html代码: <input type='checkbox' name='menuCheckBox' value='10' >苹果 <input ...
- Jquery获取当前页面中的复选框选中的内容
在使用$.post提交数据时,有一个数据是复选框获取数据,所以在当前页面获取到复选框选中的值并提交到后端卡住了一下,解决方法如下: 这两个input就是复选框的内容: str += "< ...
- CheckStateChanged(复选框选中状态更改事件)和 CheckedChanged(单选按钮选中状态更改事件)二者区别?
CheckStateChanged(复选框选中状态更改事件)和 CheckedChanged(单选按钮选中状态更改事件)二者区别: 复选框控件(CheckBox)提供了CheckedChanged控件 ...
- bootstrap table 复选框选中后,翻页不影响已选中的复选框
使用的 jquery版本为 2.1.1 在项目中发现bootstrap table的复选框选中后,翻页操作会导致上一页选中的丢失,api中的 bootstrapTable('getSelections ...
随机推荐
- 为RecyclerView的不同item项实现不同的布局(添加分类Header)
最近在做一个应用的时候,需要为GridLayoutManager添加头部header,然后自然而然就想到了用不同的itemType去加载不同的布局. 1.实现多item布局,用不同的itemType去 ...
- gulp学习-gulpfile
安装gulp 假设已经安装了node 和npm (淘宝的cnpm很适合国内使用). 1.首页全局安装gulp. 1 npm install --global gulp 2.其次局部安装gulp.(注: ...
- gloolooer
V1.2gloolooer金[http://sh.yun.ftn.qq.com/ftn_handler/0a9043ee7aa120d3c864281211dff2f08efe5e2d42438ec5 ...
- 二.TimesTen原理及应用场景
声明:本文章转自麻袋爸爸 一,TimesTen应用场景 在谈论TimesTen内存数据库应用场景之前,我们先来介绍一下什么是内存数据库,及其工作原理吧.内存数据库,顾名思义就是将数据存放在内存中,并通 ...
- UWP学习记录2-设计和UI之布局
UWP学习记录2-设计和UI之布局 1.导航基础知识 应用里,多个页面会有层次关系或者对等关系.这两种关系,通常在一个复杂应用里都会存在,而关系的选定依据: 对于对等导航,一般用选项卡(tabs)或者 ...
- #英文#品读中国城市个性——上海人的精明&头啖汤
制定"严格的规则" set the 'hard and fast' rules 担负职责 shoulder responsibility 对...有深刻理解 develop a g ...
- 【web maven】新建的项目 controller也有,从前台跳转后台 无法找到对应的controller
碰上很 愣的问题: 使用maven搭建项目完成,项目页面写好,实体.Dao.Service.Controller都有了,但是指定Controller中的某个方法中一直不能从前台进入后台 原因: 没有w ...
- react native 中webview内的点击事件传到外部原生调用
先说一下我使用webview的时候遇到的一个功能需求 是这样的,上图中的这个页面是用h5做的,但是由于点击"我的优惠劵"是需要跳转到我原生的页面,也就是说我需要获得这个h5提供的点 ...
- jquery 回车事件
简单地记下jquery实现回车事件,代码如下: 全局: $(document).keydown(function(e){ if(e.keyCode==13){ $(".login-li in ...
- 解决安装mysql的”A Windows service with the name MySQL already exists.“问题
如果以前安装过mysql,卸载重装,很可能会碰到"A Windows service with the name MySQL already exists."这样的提示.即服务已经 ...