我正在使用 Angular 15,并且我有一个由 datatables.net 包创建的数据表。 每行都有一个按钮,单击它时,它会展开并显示一个包含该行更多详细信息的表单。这就是我无法实现的,我无法获取行元素并在单击它时添加一些功能,因为我不知道该包如何处理这种情况。 我在其网站上进行了搜索,但所有答案都是旧的,并且有我找不到的课程。 有人用过这个包或者至少告诉我该怎么做吗?我完全迷路了。 预先感谢。
Check the link below:
https://l-lin.github.io/angular-datatables/#/advanced/using-template-ref
or you can use rowclick event if above not work. In that case you have to use rowCallback attribute inside datatable like below:
rowCallback: (row: Node, data: any[] | Object, index: number) => {
const self = this;
$('td', row).off('click');
$('td', row).on('click', () => {
self.someClickHandler(data);
});
return row;
}
and then define someClickHandler() function in the component.
Ref:- https://l-lin.github.io/angular-datatables/#/advanced/row-click-event