I am new to angular and ngx datatable. how to get row data on mouse click event
onClick(event) {
// I need to get row data here
}
Just use (activate)="onActivate($event)" property on ngx-datatable like this
<ngx-datatable #table
....
(activate)="onActivate($event)"
....
>
Then in TS file, use this method
onActivate(event) {
if(event.type == 'click') {
console.log(event.row);
}
}
(activate)="onActivate($event)"
OR
(select)="onSelect($event)"
onActivate(event) {
if(event.type == 'click') {
console.log(event.row);
}
}
onSelect(event) {
//event.type is undefined, use below:
console.log(event.selected);
}
(activate)
event, you will get event
, row
, rowElement
, type
(select)
event, you will only get selected
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With