首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

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

2012-10-29 
Edo gantt project.tree 复选框深度选择function setTreeSelect(sels, checked, deepSelect){//deepSelect

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

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);
?});

热点排行