show only a branch of nodes

Hello

I have a node tree that I want to show only a branch of nodes.

I want all the sub-nodes that are under the node with ID 5.

For example, in the image below, I just want to show all the nodes below Desserts  .



image.jpg

Thank you for your help.


1 Reply

IL Indhumathy Loganathan Syncfusion Team June 14, 2022 12:04 PM UTC

Hi hkourd,


Greetings from Syncfusion support.


We understand that you want to render the separate group of nodes as a TreeView. For your reference, we have prepared a sample where we retrieve the specific node details with a button click and update the TreeView with those corresponding node details. Check the below code snippet.


document.addEventListener('DOMContentLoaded', function () {

  // Create instances for TreeView element

  var treeObj = document.getElementById('hierarchical').ej2_instances[0];

  var data = treeObj.getTreeData('AS');

  // Update the data.

  document.getElementById('btn').onclick = function (e) {

      treeObj.fields = {

          dataSource: data,

          id: 'code',

          text: 'name',

          child: 'child',

      };

  };

});


Sample: https://www.syncfusion.com/downloads/support/forum/175602/ze/WebApplication1-2030372113


Please check the attached sample and get back to us if you need any further assistance.


Regards,

Indhumathy L


Loader.
Up arrow icon