如何在 Angular 5 中捕获分页按钮上一个/下一个中的点击事件。不幸的是我在 jquery 中得到了代码。
jquery 代码:
var table = $('#example').DataTable({
drawCallback: function(){
$('.paginate_button.next', this.api().table().container())
.on('click', function(){
alert('next');
});
}
});
但是我需要 Angular 数据表。如果您有一个示例,如何捕获上一个/下一个点击事件。
按钮行点击事件
buttonInRowClick(event: any): void {
event.stopPropagation();
console.log('Button in the row clicked.');
}
整行点击事件
wholeRowClick(): void {
console.log('Whole row clicked.');
}
预期下一个/上一个按钮单击事件
nextButtonClickEvent():void {
//do next particular records like 101 - 200 rows.
//we are calling to api
}
previousButtonClickEvent():void {
//do previous particular the records like 0 - 100 rows.
//we are calling to API
}
因为我的后端有数千条记录。
最佳答案
我推荐使用ngx-datatable库,非常完整且易于使用!即使文档也很好! https://github.com/swimlane/ngx-datatable
关于javascript - 如何捕获 DataTables Angular 5 的下一个/上一个分页按钮上的单击事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52406006/