我有一个json数据是这种形式
[ { id: '1', name: 'Plant Director', parentJobID: -1 },
{ id: '19', name: 'Operations Director', parentJobID: 1 },
{ id: '16',
name: 'Financial planning and costs Manager',
parentJobID: 19 },
{ id: '14', name: 'Cost Analyst', parentJobID: 16 },
{ id: '15', name: 'Head of Costs', parentJobID: 16 },
{ id: '17', name: 'Manufacturing Manager', parentJobID: 19 },
{ id: '2', name: 'Head of Security', parentJobID: 17 },
{ id: '3', name: 'Asistente Ejecutiva', parentJobID: 2 },
{ id: '8', name: 'Jefe de Mantenimiento', parentJobID: 2 },
{ id: '27',
name: 'Jefe Aseguramiento de Calidad',
parentJobID: 2 },
{ id: '28', name: 'Jefe Seguridad Alimentaria', parentJobID: 27 },
{ id: '33', name: 'Operario Fabricación A (2)', parentJobID: 28 },
{ id: '34', name: 'Operario Fabricación B (2)', parentJobID: 28 },
{ id: '29',
name: 'Especialista Aseguramiento de Calidad',
parentJobID: 27 },
{ id: '30',
name: 'Especialista en Microbiología',
parentJobID: 27 },
{ id: '31',
name: 'Especialista en Evaluación Sensorial',
parentJobID: 27 },
{ id: '32',
name: 'Técnico Aseguramiento de Calidad',
parentJobID: 27 },
{ id: '4', name: 'Production Manager', parentJobID: 17 },
{ id: '5', name: 'Head of Maintenance', parentJobID: 17 },
{ id: '6', name: 'Quality Control Manager', parentJobID: 17 },
{ id: '7', name: 'Técnico Medio Ambiente', parentJobID: 6 },
{ id: '23',
name: 'Quality Control Technician 1',
parentJobID: 6 },
{ id: '25', name: 'Operario Fabricación B', parentJobID: 23 },
{ id: '26', name: 'Operario Fabricación D', parentJobID: 23 },
{ id: '24',
name: 'Quality Control Technician 2',
parentJobID: 6 },
{ id: '9', name: 'Warehouse Manager', parentJobID: 17 },
{ id: '10', name: 'Head of Planning', parentJobID: 17 },
{ id: '20', name: 'Operario Mtto A (2)', parentJobID: 10 },
{ id: '11',
name: 'Head of Continuous Improvement',
parentJobID: 17 },
{ id: '21', name: 'Operario Servicios A (2)', parentJobID: 11 },
{ id: '12', name: 'Head of Supplies', parentJobID: 17 },
{ id: '13', name: 'Process Manager', parentJobID: 17 },
{ id: '18', name: 'IT Manager', parentJobID: 17 },
{ id: '35', name: '[ LINEA DE PRODUCCION ]', parentJobID: 1 },
{ id: '22', name: 'Extrusion Area', parentJobID: -1 } ]
然后我将其更改为层次结构形式,如:
[ { id: '1',
name: 'Plant Director',
parentJobID: -1,
children: [ [Object], [Object] ] },
{ id: '22',
name: 'Extrusion Area',
parentJobID: -1,
children: [] } ]
我希望像这样表现出来 http://www.jqueryscript.net/demo/jQuery-Plugin-To-Create-Checkbox-Tree-View-highchecktree/但是在这个他们使用的项目标签不在我的回复中我需要改变这种形式的josn
item:{
id: '1',
label: 'Plant Director',
checked: false
},
children: [{
item:{
id: '19',
label: 'Operations Director',
checked: false
}
},{
item:{
id: '35',
label: '[ LINEA DE PRODUCCION ]',
checked: false
}
}
}]