Can i select default value in a treeView

is it possible to select a default node programmatically in a treeview ? for exemple i want to select the node one by default  when the page is loaded.

Thanks for your answer.



1 Reply

IL Indhumathy Loganathan Syncfusion Team March 22, 2022 06:49 AM UTC

Hi Arnaud, 
 
In TreeView component, we have selected property in fields property. By enabling this in corresponding node datasource, you can select the TreeView nodes at initial rendering. Check the below code snippet. 
 
  public hierarchicalData: Object[] = [ 
    { 
      id: '01', 
      name: 'Local Disk (C:)', 
      expanded: true, 
      isSelected: true, 
      ... 
  ]; 
  // Mapping TreeView fields property with data source properties 
  public field: Object = { 
    dataSource: this.hierarchicalData, 
    id: 'id', 
    text: 'name', 
    child: 'subChild', 
    selected: 'isSelected', 
  }; 
 
 
Please check the sample and get back to us if you need any further assistance. 
 
Regards, 
Indhumathy L 


Loader.
Up arrow icon