角度7-重新加载数据表中的数据 [英] angular 7 - reload data in data table
本文介绍了角度7-重新加载数据表中的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在将angular 7与angular-datatables一起使用. 我正试图定义一个渲染"按钮,以便重新加载数据就像在这个例子中一样.
I'm using angular 7 with angular-datatables. I'm tring to define a "rerender" button in order to reload data like in this example.
我不明白我应该在渲染函数中放置什么:
I don't understand what should I place in the render function:
我的API函数:
fn_getFavoriteTables() {
this._getFavoriteTablesApiCall = this.getFavoriteTablesService.getFavoriteTables(Number(localStorage.getItem('UserID')), Number(localStorage.getItem('BranchID'))).pipe(takeUntil(this.destroySubject$)).subscribe(x => {
this.getFavoriteTables = x;
this.dtTrigger.next();
});
};
渲染功能:
rerender(): void {
this.dtElement.dtInstance.then((dtInstance: DataTables.Api) => {
// Destroy the table first
dtInstance.destroy();
// Call the dtTrigger to rerender again
this.dtTrigger.next();
});
}
ngOnDestroy(): void {
console.log('ngDestroy');
// Do not forget to unsubscribe the event
this.dtTrigger.unsubscribe();
}
推荐答案
找到了对我有用的答案: 这是源站点
Found an answer that worked for me: this is the source site
rerender(): void {
this.dtElement.dtInstance.then((dtInstance: DataTables.Api) => {
// Destroy the table first
//debugger;
var table = $('#favoriteTable').DataTable();
$('#tableDestroy').on('click', function () {
table.destroy();
});
dtInstance.destroy();
this.fn_getFavoriteTables();
});
}
这篇关于角度7-重新加载数据表中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文