Currently, I am utilizing Jqtree to create a drag and drop tree structure. My main goal is to customize the appearance of the tree based on different node levels.
Javascript Tree Structure
var data = [
{
name: 'node1', id: 1,
children: [
{ name: 'child1', id: 2 },
{ name: 'child1', id: 2, children: [
{ name: 'child7', id: 7 },
{ name: 'child7', id: 8 } ] },
{ name: 'child2', id: 3 }
]
},
{
name: 'node2', id: 4,
children: [
{ name: 'child3', id: 5 },
{ name: 'child4', id: 6 }
]
}
];
$('#tree1').tree({
data: data,
autoOpen: true,
dragAndDrop: true
});
Code snippet for displaying the tree
$(function() {
$('#tree1').tree({
data: data,
autoOpen: true,
dragAndDrop: true
});
Although I have gone through the jqtree documentation, I am still unsure about how I can apply custom styles or code specific to the results generated by the 'data' variable.
var node = $('#tree1').tree('getNodeById', 123);
var treelevel = node.getLevel();