$(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
// for(var k = 0;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
// for(var k = 0;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
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 );
}
}
}
}
*/
})
标签:function,easyui,递归,text,岗位,children,选中,var,id
来源: https://www.cnblogs.com/smile-fanyin/p/11133412.html