We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Template with buttons

Thread ID:





142504 Feb 6,2019 06:51 PM UTC Feb 12,2019 12:24 PM UTC JavaScript - EJ 2 5
Tags: TreeView
Asked On February 6, 2019 06:51 PM UTC

How do i set up my template to have a button. I can't seem to get the button to get the click

Christopher Issac Sunder K [Syncfusion]
Replied On February 7, 2019 08:41 AM UTC

Hi Mike, 

Thank you for contacting Syncfusion support. 

In our TreeView component, we have disabled the pointer events for tree node full row element. Your reported problem can be resolved by manually setting the pointer events to the button component rendered inside TreeView template which is used to render tree nodes. Please find the code below. 

//Apply style for button element 
.treeCount.e-badge { 
    pointer-events: auto; 

For that sample, we have bounded the click event for count badge(showcased in right side of tree), please check it. 

Let us know if you require any further assistance. 


Replied On February 7, 2019 10:45 AM UTC

Thank you, that works. Shortly after I asked the question I came across the angular question with the same subject.   I'm defining my html as a string in javascript because I'm using Aurelia and Aurelia tries to process the template if it is on the page.  How do I get context back to the javascript function?  Your sample has the function in a script on the same page.  Is there also a way to get the event data like the angular sample shows?

Christopher Issac Sunder K [Syncfusion]
Replied On February 8, 2019 10:52 AM UTC

Hi Mike, 

Thanks for the update. 

We checked your query. For this, you can define the treeview template inline using nodeTemplate property to achieve your requirement. Please check below code block and sample, 
<ejs-treeview id="template" [fields]="field" [nodeTemplate]="nodeTemplate"> 

public nodeTemplate = '<div><div class="treeviewdiv"><div style="float:left"><span class="treeName">${name}</span></div>${if(count)}<div style="margin-right: 5px; float:right"><button class="treeCount e-badge e-badge-primary" onclick="treebuttonclick()">${count}</button></div>${/if}</div></div>'; 
Api Documentation: 

Please let us know if you require any further assistance. 


Replied On February 8, 2019 11:29 AM UTC

I think you misunderstood my question.  I'm not using angular.  I'm using the javascript version with aurelia.  Aurelia should not be relevant for the issue.  Again, I am NOT using angular.

No matter if i define the template in the html or in the TS, the template is in the wrong context to call my button clicked event.

Christopher Issac Sunder K [Syncfusion]
Replied On February 12, 2019 12:24 PM UTC

Hi Mike, 

Thanks for the update. 

We have prepared sample based on your requirement. In this, we have handled the button click event in the same .ts page itself through the created event of treeview. And also you can access the treeview details in this event. 

Please let us know if you require any further assistance. 



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon