zoukankan      html  css  js  c++  java
  • 递归选中easyui树

     $(function(){
            // var data1 = [
            //     {
            //         "id": 3,
            //         "text": "3组织",
            //         "state": "open",
            //         "children": [
            //             { "id": 4,"text": "4岗位"},
            //             {"id": 5,"text": "5岗位", 
            //                 "children":[
            //                     {
            //                         "text":"6岗位",
            //                         "id":'_6'
            //                     },{
            //                         "id": '_7',
            //                         "text":"7岗位"
            //                     }
            //                 ]
            //             },
            //             {"id": '_8',"text": "8岗位"}
            //         ]
            //     },
            //     {"id": 9,"text": "9岗位"}
            // ];
            
            
    
            // function isChecked(data,arr){
            //     for(var i=0;i<arr.length;i++){
            //         for(var k = 0;k<data.length;k++){
            //             if(data[k].children==null || data[k].children.length<=0 ){
            //                 console.log( data[k].text );
            //                 if( data[k].id == arr[i] ){
            //                     data[k]["checked"]=true;
            //                 }
            //             }else{
            //                 if( data[k].id == arr[i] ){
            //                     data[k]["checked"]=true;
            //                 }else{
            //                     isChecked( data[k].children,[arr[i]] );
            //                 }
            //             }
    
            //         }
            //     }
            // }
            
            // var data1 = [
            //     {"id": 9,"text": "9岗位"},
            //     {
            //         "id": 3,
            //         "text": "3组织",
            //         "state": "open",
            //         "children": [
            //             { "id": '_4',"text": "4岗位"},
            //         ]
            //     }
            // ];
            // var arrId = ['4',6,7,8];
            // function isChecked(data,arr){
            //     for(var i=0;i<arr.length;i++){
            //         for(var k = 0;k<data.length;k++){
    
            //             if( (data[k].id+'').includes("_")  ){
            //                 console.log( "走含有_的路径" );
            //                 if(data[k].children==null || data[k].children.length<=0 ){
            //                     // console.log( data[k].text );
            //                     if( data[k].id.split("_")[1] == arr[i] ){
            //                         data[k]["checked"]=true;
            //                     }
            //                 }else{
            //                     if( data[k].id.split("_")[1] == arr[i] ){
            //                         data[k]["checked"]=true;
            //                     }else{
            //                         isChecked( data[k].children,[arr[i]] );
            //                     }
            //                 }
            //             }else if( !(data[k].id+'').includes("_")){
            //                 console.log( "no!!!走不含有_的路径" );
            //                 if(data[k].children==null || data[k].children.length<=0 ){
            //                     // console.log( data[k].text );
            //                     if( data[k].id == arr[i] ){
            //                         data[k]["checked"]=true;
            //                     }
            //                 }else{
            //                     if( data[k].id == arr[i] ){
            //                         data[k]["checked"]=true;
            //                     }else{
            //                         isChecked( data[k].children,[arr[i]] );
            //                     }
            //                 }
            //             }
    
                        
    
            //         }
            //     }
            // }
    
            
            // isChecked(data1,arrId);
            // $("#dimensionTree").tree({
            //     data: data1,
            //     checkbox:true,
            //     animate:true
            // });
    
            //渲染树之前搞递归选中
            /*
            var data = [
                {"id": 9,"text": "9岗位"},
                {
                    "id": 3,
                    "text": "3组织",
                    "state": "open",
                    "children": [
                        { "id": 4,"text": "4岗位"},
                    ]
                }
            ];
            isChecked(data);
            $("#dimensionTree").tree({
                data: data,
                checkbox:true,
                animate:true
            });
            function isChecked(data){
                var myId = 4; //此处需要循环id
                for(var k = 0;k<data.length;k++){
                    if(data[k].children==null || data[k].children.length<=0 ){
                        console.log( data[k].text );
                        if( data[k].id == myId ){data[k]["checked"]=true;}
                    }else{
                        if( data[k].id == myId ){data[k]["checked"]=true;}else{
                            isChecked( data[k].children );
                        }
                    }
    
                }
            }
    
            */
        })
        
  • 相关阅读:
    R语言实战学习总结
    R语言学习笔记(十七):高级绘图ggplot2
    R语言学习笔记(十六):处理缺失值
    R语言学习笔记(十五):分类
    R语言学习笔记(十四):聚类分析
    R语言学习笔记(十三):时间序列
    R语言学习笔记(十二):主成分分析和因子分析
    转:网页不应该出现的特殊字符
    转:html常用网页特殊字符代码大全,值得收藏!
    转:LoadRunner 12 安装教程
  • 原文地址:https://www.cnblogs.com/smile-fanyin/p/11133412.html
Copyright © 2011-2022 走看看