Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Binding click event to expansion icon in tree table

I am working on angular app. I am using tree table from primeng. In this tree table I have a expansion icon. Code is as follows:

Stackblitz :

https://stackblitz.com/edit/primeng-treetablestyle-demo

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I want to bind a (click) event on this expansion panel and pass data to component on click of expansion icon and to want to know if it is expanded or not. I tried giving following code in div and tried binding click event to it, but it is not working

  <div (click)="toggleClicked(data)">  <p-treeTableToggler [rowNode]="rowNode" *ngIf="i == 0"></p-treeTableToggler> </div>

how can I do that?

>Solution :

There is an (onNodeExpand) method written on <p-treeTable></p-treeTable> tag. You can write a function and pass $event to that function and know when your tree is expanded

 <p-treeTable (onNodeExpand)="onNodeExpand($event)" ... > 
  ...
  <p-treeTableToggler [rowNode]="rowNode" *ngIf="i == 0"></p-treeTableToggler>
 </p-treeTable>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading