问题描述
我正在从事基于角度的项目.我正在使用数据表来显示数据.当我尝试在表上进行一些修改时,出现以下错误.
I am working on the angular based project. I am using datatables to display data. When I try to do some modifications on the table, I get the following error.
DataTables警告:表ID = DataTables_Table_0-无法重新初始化DataTable.有关此错误的更多信息,请参见 http://datatables.net/tn/3
DataTables warning: table id=DataTables_Table_0 - Cannot reinitialise DataTable. For more information about this error, please see http://datatables.net/tn/3
推荐答案
我认为这是因为您正在Angular DataTables中使用[dtTrigger]="dtTrigger"
并在同一页面上重新呈现该表.如果遇到此问题,则应使用以下技巧来处理dtTrigger
I think it is because you are using [dtTrigger]="dtTrigger"
in Angular DataTables and rerendering the table on the same page. If you have this problem you should use the following trick to handle dtTrigger
<table datatable [dtOptions]="dtOptions" [dtTrigger]="dtTrigger" class="table">
确保不要在ngOnInit()
上使用this.dtTrigger.next()
ngAfterViewInit(): void {this.dtTrigger.next();}
第二次使用时将其渲染
rerender(): void {
this.dtElement.dtInstance.then((dtInstance: DataTables.Api) => {
dtInstance.destroy();
this.dtTrigger.next();
});
这篇关于在Angular 5数据表中出现错误:无法重新初始化数据表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!