注:当node选中, childNodes逐级全部选中. parentNode当子node全部选中时逐级自动选中,nodes未全部选中, parentNode逐级自动取消选中

在javascript中加入下面的代码,

/*向上遍历父结点*/
var nodep=function(node){
var bnode=true;
Ext.Array.each(node.childNodes,function(v){
if(!v.data.checked){
bnode=false;
return;
}
});
return bnode;
};

var parentnode=function(node){
if(node.parentNode != null){
if(nodep(node.parentNode)){
node.parentNode.set('checked', true);
}else{
node.parentNode.set('checked', false);
}
parentnode(node.parentNode);
}
};

/*遍历子结点 选中 与取消选中操作*/
var chd=function(node,check){
node.set('checked',check);
if(node.isNode){
node.eachChild(function (child) {
chd(child,check);
});
}
};

/*treepanel为tree名称*/
treepanel.on('checkchange', function (node, checked) {
if(checked){
node.eachChild(function (child) {
chd(child,true);
});
}else{
node.eachChild(function (child) {
chd(child,false);
});
}
parentnode(node); //进行父级选中操作
},treepanel);

Extjs4.x完美treepanel checkbox无限级选中与取消的更多相关文章

  1. TreeView控件的CheckBox级联选中或取消

    背景: 在一个项目开发中遇到这样的要求:当选中树中一个节点时,需要同时选中其父节点,直至根节点.在取消一个节点的选中时,需要将其所有子节点取消选中,直至叶子节点.由于项目用户体验暂时可以不用考虑,直接 ...

  2. CSS冲突1 要关掉的css在项目内:【material-table】 中 checkbox 点击checkbox无法选中or取消,点击旁边才能选中or取消

    CSS优先级: !important > 行内样式 > 内嵌样式|链接外部样式(哪个在后面哪个优先级大) id选择器 > class选择器 > 元素选择器 react中好像还不 ...

  3. Jquery选中行实现行中的Checkbox的选中与取消选中

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs& ...

  4. jQuery处理点击父级checkbox所有子级checkbox都选中,取消选中所有子级checkbox都取消

    注意,每个foreach标签内部都加一个div用来区分各个层次关系,模板代码如下: <foreach name='node' item='v'> <div class='a' ali ...

  5. jquery checkbox (选中和取消选中事件on("change"))做笔记

    $("#btn_Company").attr("disabled", "disabled"); $("#agency") ...

  6. MVC项目中使用js 设置Checkbox的选中事件

    要实现的效果是,当点击checkbox时,跳转到Action中 CheckBox实例: View界面: @Html.CheckBox("prd.IsChecked", Model. ...

  7. ----------jqery和js如何判断checkbox是否选中 --------两个单选按钮如何选一个,且用jquery获取被选的值

    jqery和js如何判断checkbox是否选中 jquery: <div id="divId" class="divTable"> <div ...

  8. JQuery判断checkbox是否选中-批量

    在html的checkbox里,选中的话会有属性checked="checked". 如果用一个checkbox被选中,alert这个checkbox的属性"checke ...

  9. jQuery和js如何判断checkbox是否选中

    jquery: <div id="divId" class="divTable"><div class="tableBody&quo ...

随机推荐

  1. css“变形”效果

    <html <head> <title></title> <style> .test { margin-left:300px; margin-to ...

  2. 消息队列系列(一):.Net平台下的消息队列介绍

    本系列主要记录最近学习消息队列的一些心得体会,打算形成一个系列文档.开篇主要介绍一下.Net平台下一些主流的消息队列框架.       RabbitMQ:http://www.rabbitmq.com ...

  3. 将java.util.Date类型转换成json时,使用JsonValueProcessor将date转换成希望的类型

    问题描述: java里面时间类型转换成json数据就成这样了: "createTime":{"date":30,"day":3," ...

  4. interview review

    缘起: 因为最近要找工作,自己总结了一下面试的注意事项. 1自我介绍方法 1.基本情况:姓名.年龄.学历.家庭与理想. 简单明了,不要啰嗦. 2.学习能力:专业知识.勤奋好学. 用事实说明学习能力不错 ...

  5. ECSHOP不同商品分类调用不同模板

    1.在ecs_category 表 添加 template 字段 可以在后台运行sql语句:alter table `ecs_category` Add column template text NO ...

  6. Java Difference between Private and Protected

    Private means this could only be seen within this class. Protected means "package private" ...

  7. Oracle deadlock SX/SSX caused by no index on foreign key.

    Example to show the dead lock caused by lack of index on foreign key of child table. Session 1: crea ...

  8. php命名空间详解

    index.php: <?php include 'demo.php'; use A\demo as test; use B\demo as test2; use C\demo; $obj = ...

  9. Hibernate中in语句ids

    Query query=session.createQuery("from User where id in (:ids)"); query.setParameterList(&q ...

  10. MVC 应用程序级别捕捉异常

    捕捉异常: using System; using System.IO; using System.Net; using System.Net.Http; using System.Net.Http. ...