当前位置: 首页 > 工具软件 > Gantt Project > 使用案例 >

Edo gantt project.tree 复选框深度选择

章子航
2023-12-01

function setTreeSelect(sels, checked, deepSelect){//deepSelect:是否深度跟随选择
     //多选
     if(!Edo.isArray(sels)) sels = [sels];
     project.tree.data.beginChange();
     for(var i=0,l=sels.length; i<l; i++){
         var r = sels[i];       
         var cs = r.children;       
         if(deepSelect){
             project.tree.data.iterateChildren(r, function(o){
                 this.data.update(o, 'checked', checked);
             },project.tree);
         }
         project.tree.data.update(r, 'checked', checked);
     }
     project.tree.data.endChange();
 }
 // 获取选中
 function getTreeSelect(tree){
     var sels = [];
     tree.data.source.each(function(node){       
         if(node.checked) sels.add(node);
     });
     return sels;
 }

 //增加功能: 1.选择行任意部分, 都对节点进行折叠操作; 2.节点列显示一个手型,参考本页面的e-tree-treecolumn样式定义
 project.tree.on('bodymousedown', function(e){
     var r = this.getSelected();
     if (r){
      var parentNode = project.tree.data.findParent(r);
       while (parentNode !== undefined) { // 循环设置父任务的checked 为true
        project.tree.data.update(parentNode, 'checked', true);
              parentNode = project.tree.data.findParent(parentNode);
          }
       // 子任务的的checked属性的设置
       var inCheckIcon = Edo.util.Dom.hasClass(e.target, 'e-tree-check-icon');
         var hasChildren = r.children && r.children.length > 0;
         if(inCheckIcon && r.checked){
             setTreeSelect(r, false, true);
         }else{
             setTreeSelect(r, true, true);
         }
     }    
    
     getTreeIdsSelect(project.tree);
 });

 类似资料: