Hi Brent,
Greetings from
Syncfusion support.
As requested, we have
added proper type declaration to remove the //@ts-ignore tags. Check out
the below code snippet.
|
const addTreeNode = () => {
let treeview = treeviewRef.current;
if (treeview) {
let data = getTreeViewData();
const selectedId = treeview.selectedNodes[0];
const
newNode = JSON.parse(JSON.stringify(new
TreeViewNode(name, getNextId(data), selectedId)));
treeview.addNodes([newNode], selectedId)
setName("");
}
}
function getNextId(data: any) {
if (data.length === 0)
return 1;
return data.sort((a: any, b: any) => a.Id - b.Id)[data.length - 1].Id + 1
}
function getTreeViewData() {
return treeviewRef.current?.getTreeData();
}
|
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/treeviewtesting1034963722
Check out the sample
and get back to us if you need any further assistance.
Regards,
Indhumathy L