draw

draw

mfonmfon Posts: 2Questions: 1Answers: 0

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:

Answers

  • mfonmfon Posts: 2Questions: 1Answers: 0

    I am trying to reinitialize my datatable after an item has been removed from the array

    S/N Response Taget Page Action
    {{i+1}} {{item.response}} {{item.targetPage}} X

    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

  • kthorngrenkthorngren Posts: 21,073Questions: 26Answers: 4,905

    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

Sign In or Register to comment.