draw
draw
mfon
Posts: 2Questions: 1Answers: 0
Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:
Answers
I am trying to reinitialize my datatable after an item has been removed from the array
this is my ts
@ViewChild(DataTableDirective, { static: false })
dtElement: DataTableDirective;
dtOptions: DataTables.Settings = {};
dtTrigger: Subject<any> = new Subject<any>();
RemoveItem = (id: any) => {
if(!this.isConfigured) {
const findIndex: any = this.displayTextArray?.findIndex(a => a.pageIndex === id)
findIndex !== -1 && this.displayTextArray?.splice(findIndex, 1)
if (this.displayTextArray.length === 0) {
this.disableSubmit = true
}
}
else if(this.isConfigured) {
const findIndex: any = this.pagesSelected?.findIndex(a => a.pageIndex === id)
findIndex !== -1 && this.pagesSelected?.splice(findIndex, 1)
if (this.pagesSelected?.length === 0) {
this.disableSubmit = true
}
this.clearAndDestroyDataTable();
}
}
async clearAndDestroyDataTable(): Promise<void> {
if (this.dtElement && this.dtElement.dtInstance) {
(await this.dtElement.dtInstance).clear().rows.add(this.pagesSelected as any[]).draw();
} this.dtTrigger.next('');
}
i am getting this error message
DataTables warning: table id=myTable - Requested unknown parameter '0' for row 0, column 0. For more information about this error, please see http://datatables.net/tn/4
Start by following the troubleshooting steps found at the link in the error:
https://datatables.net/manual/tech-notes/4
Sounds like data structure of the rows being added isn't correct. Start by verifying what is being added. For help debugging please provide a link to your page or a test case replicating the issue.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin