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

Template with buttons

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

5 Replies

CI Christopher Issac Sunder K Syncfusion Team 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. 

Thanks, 
Christo 



MI Mike 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?


CI Christopher Issac Sunder K Syncfusion Team 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, 
 
[HTML] 
<ejs-treeview id="template" [fields]="field" [nodeTemplate]="nodeTemplate"> 

[TS] 
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>'; 
 
Sample: 
 
Api Documentation: 

Please let us know if you require any further assistance. 

Thanks,
Christo



MI Mike 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.


CI Christopher Issac Sunder K Syncfusion Team 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. 

Thanks, 
Christo

Loader.
Live Chat Icon For mobile
Up arrow icon