// Render the TreeView by mapping its fields property with data source properties
let treeObj: TreeView = new TreeView({
fields: { dataSource: (dataSource as any).defaultData, id: 'id', text: 'name', child: 'subChild', selected: 'isSelected' }
});
treeObj.appendTo('#tree');
document.getElementById("btn").onclick = (): void => {
let node = [
{ "id": "02-01-01", "name": "My photo.png", "isSelected": true }];
treeObj.addNodes(node, "01-01", null, false); //adding the node to parent node with id 01-01
} |
//selected attribute mapping field and newly added node data's selected field values should be same
let treeObj: TreeView = new TreeView({
fields: { dataSource: (dataSource as any).defaultData , id: 'id', text: 'name', child: 'subChild', selected: 'isSelected' }
});
let node = [
{ "id": "02-01-01", "name": "Root Node", "isSelected": true }];
treeObj.addNodes(node, null, null, false); //adding the node to Root Level |