Hi Rajender,
Greetings from Syncfusion Support.
We checked your requirement “I want to restrict the treeview only till 2 levels or may be 3 levels in future if required. Is there any configuration that cn be used and restrict the user to create only 2 level treeview”. We would like to mention that the initial rendering of TreeView levels depends on the structure of your data source. When rendering the TreeView, you can choose the data to be only at certain levels, i.e., the child nodes of the required TreeView must be provided according to your requirement. And we have created a sample over here to restrict the drag and drop action in level 2 through args.cancel. You can customize this levels based on your requirement.
Refer to the code snippet.
|
function onNodeDragStop(args) {
if (args.droppedNodeData != null) {
var droppeddata = document.querySelector(
'[data-uid="' + args.droppedNodeData.id + '"]'
).classList[1];
if (droppeddata == 'e-level-2') {
args.cancel = true;
}
}
} |
Refer to the sample.
Please get back to us if you need further assistance.
Regards,
Sharon Sanchez S.