Search code examples
angularprimengprimeng-datatable

How to access the data when using expandable rows in primeng's datatable


When using primeng there's the following method to expand a row. I want to access the selected row's data to send a call to the server and expand the row when the data returns.

According to documentation, there's this (onRowClick)="dt.toggleRow($event.data)" call back, and the data is accessible using angular's double bracket notation {{id}}. However, how would I access the data from the selected row in typescript and not in html?


Solution

  • I think what you are asking is how do you access the data from the onRowClick method?

    If that is what you are wanting to know, I think that if you defined your onRowClick event call like this:

    (onRowClick)="dt.toggleRow($event.data); rowClicked($event.data)"
    

    you will then have access to the data of the row clicked in your rowClicked method.