¿How can i add a icon in a node selected to add or delete functionality?

Hi!

I have a TreeView and i need add a button ( add or remove ) in right of text from node selected.

example: 



¿How can i add it?

Regards.

1 Reply

SP Sowmiya Padmanaban Syncfusion Team April 2, 2020 12:57 PM UTC

Hi Víctor,  
 
Greetings from Syncfusion support. 
 
We have checked your reported requirement on TreeView component. Yes, it is possible to add the icons in the nodes of the TreeView component. You can add the icon using NodeTemplate of TreeView component. Refer the below code snippet. 

 <TreeViewComponent fields={this.fields} nodeTemplate={this.nodeTemplate} cssClass={this.cssClass}/> 
    nodeTemplate(data) { 
        return (<div> 
            <div className="treeviewdiv"> 
              <div className="textcontent"> 
                <span className="treeName">{data.name}</span> 
              </div>           
            <div className="countcontainer"> 
                  <span className="e-icons e-delete"></span> 
                </div> 
            </div> 
          </div>); 
    } 
    .e-delete:before{ 
        content: '\e932'; 
    } 
 /* If you want perform any operation using icons. set the pointer events as auto. It triggers the click event for icon.*/ 
    .e-treeview.e-fullrow-wrap .e-text-content { 
      pointer-events: auto; 
    } 
 


Check out the following sample which has the above explained solution. 
 
 
Refer the below link to know  about icons available in EJ2. 
 
 
To know more about TreeView component. Refer the below links. 
 
 
 
 
Please let us know, if you need any further assistance. 
 
Regards,  
Sowmiya.P 


Loader.
Up arrow icon