Row Click event not working with Angular

Row Click event not working with Angular

chr1sosclchr1soscl Posts: 3Questions: 0Answers: 0

I am using datatables for Angular, but when implementing a call back in options to trigger a Row event click, it is not working, I am trying to print the row to the logs, but event don't seem to be triggering.
Code:
rowCallBack: (row: Node, data: any[] | Object, index: number) => {
const self = this;
// Unbind first in order to avoid any duplicate handler
// (see https://github.com/l-lin/angular-datatables/issues/87)
$('td', row).unbind('click');
$('td', row).bind('click', () => {
console.log(data);
});
return row;
}

Duplicate the issue in this link:
https://generic-table.herokuapp.com/

Please inspect logs to see details.

Replies

  • kthorngrenkthorngren Posts: 21,173Questions: 26Answers: 4,923
    edited December 2020

    Sounds like the issue is specific to Angular Datatables. Have you checked with the developers of Angular Datatables? The github issue you linked to has this comment:

    Basically, every time that you draw rows to the table to be displayed, rowCallback adds a click handler to the row regardless if the row already has one.

    AFAIK Datatables doesn't add click handlers with rowCallback. If this is something Angular Datatables does then you will need to find out from them how to handle it.

    Not sure if it will work with Angular Datatabes but this example shows the recommended way to create a row click handler.

    Kevin

This discussion has been closed.