How to delete all rows to refresh data?

How to delete all rows to refresh data?

GeasLuGeasLu Posts: 12Questions: 3Answers: 0
edited November 2020 in Free community support

Hi at all,
i use a datatable to show some details-data in a modal form. When the user click on a person, the datatable shown his details-data, like name, surname, date born... so everytime he change the data, the datatable have to change.

Now I'm using :
in the top of my function

var dtb;  

then in the ajax-jquery-call:


success: dtb = $('#' + pIdDataTable).DataTable({ destroy: true, responsive: true, data : elnParamOspite, dataSrc : "ElnParametriOspite", selectType : "row", columns: [ { // 0 data: "ID_ROW", title : 'ID_ROW', visible : false }, ....etc...

to initialize my datatable, every time the modal closed and change person select.

Everything it's ok, but when i have to read which row is clicked with this function:


$('#' + pIdDataTable).on('click', 'tbody td', function () { let indRow = this._DT_CellIndex.row; var indCol = this._DT_CellIndex.column; var idUserLogin = $('#idUserLogin').val(); if (indRow > -1) { var rowData = dtb.row(this).data(); <---------------------------------------- HERE IS THE ERROR switch (dtb.column(indCol).header().textContent){ ....etc....

there was an error:

"dtb is undefined"

can anyone help me?

thanks

Replies

  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    I suspect the variable dtb is out of scope. We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

This discussion has been closed.