Filtering a table

Filtering a table

juan_araucojuan_arauco Posts: 2Questions: 1Answers: 0

Hello, im having a problem with filtering my table, there seems to be an error when declaring table = $(#control...

$(document).ready(function () {
$.fn.dataTable.moment('DD-MM-YYYY');
$("#control_mig_tbl").DataTable({
  "order": [ 0, "desc" ],
    language: {
    url: '../../javascript/datatables/dataTables.spanish.json'
  },
   aoColumnDefs: [{
    bSortable: false,
    aTargets: 'sorting_disabled',
  }]
});
});


function misIncidentes(){
 table = $("#control_mig_tbl").DataTable();
  if (document.getElementById("Check").checked == true){
    table.column(5).search("PEREZ SELIS").draw(); // Luego se tiene que reemplazar por una variable que tenga la ubicacion del usuario
  }
  else{
    table.column(5).search("").draw();
  }
}

Thank you for reading

Answers

  • kthorngrenkthorngren Posts: 20,139Questions: 26Answers: 4,735
    edited February 2023

    there seems to be an error when declaring table = $(#control...

    There is nothing obvious that stands out as an error. What is the error? Please provide details of the problem. Do you get errors in the browser's console?

    The best way for su to help is to see the problem. Please post a link to your page or a test case replicating the issue so we can help debug.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • juan_araucojuan_arauco Posts: 2Questions: 1Answers: 0

    I get this error

  • kthorngrenkthorngren Posts: 20,139Questions: 26Answers: 4,735

    Did you follow the troubleshooting steps at the link provided?
    https://datatables.net/manual/tech-notes/3

    The error suggests you are using $("#control_mig_tbl").DataTable() somewhere before the Datatables initialization in line 3. The code snippets don't offer enough information to help debug why you are getting the Cannot reinitialize error. Please post a link to a test case showing the error so we can see your code flow.

    Kevin

Sign In or Register to comment.