Error: Datatables Warning: table id=datatable-checkbox - Cannot reinitialise Datatable - JQUERY

Asked

Viewed 1,386 times

0

I have the following problem in building a datatable:

Datatables Warning: table id=datatable-checkbox - Cannot reinitialise Datatable. For more information about this error, Please see http://datatables.net/tn/3

Well, I tried to use Destroy and I wasn’t very successful!

Code:

function retorna_cliente()
{
 $('.mostra_clientes .table').DataTable({
  "pageLength": 4,
  "ajax": {
    "url": url_base + "clientes",
    "type": "GET",
    "dataSrc": "",
  },
  "columns": [
    {
      "data": function ( data, type, row ) {
        return "<input type='checkbox' value='"+data['id']+"' name='verifica_check_box[]' id='verifica_check_box' class='flat'/>";
      }
    },
    { "data":"nome"},
    { "data":"data_nascimento"},
    { "data":"telefone"},
    { "data":"celular"},
    { "data":"cpf"},
    { "data":"endereco"},
    { "data":"email"},

  ], language: {
    "sProcessing":   "Carregando...",
    "sLengthMenu":   "Mostrar _MENU_ registros",
    "sZeroRecords":  "Não foram encontrados resultados",
    "sInfo":         "Mostrando de _START_ até _END_ de _TOTAL_ registros",
    "sInfoEmpty":    "Mostrando de 0 até 0 de 0 registros",
    "sInfoFiltered": "(filtrado de _MAX_ registros no total)",
    "sInfoPostFix":  "",
    "sSearch":       "Buscar:",
    "sUrl":          "",
    "oPaginate": {
      "sFirst":    "Primeiro",
      "sPrevious": "Anterior",
      "sNext":     "Seguinte",
      "sLast":     "Último"
    }
  },
  "bDestroy": true,
 });
}
  • If you just want to re-export ajax, you can just call oTable.ajax.reload(null, false);. oTable would be the object that is returned by .DataTable(). To destroy the table and recreate it, use oTable.destroy();.

  • @L.Albano. I did exactly what you asked but the table does not work. The next and Prev buttons do not work.

1 answer

1

Something similar has happened to me in the case two initializations (an overview of the site and one of the screen in question) of the Datatables for the same table. To solve only changed the selectors to select different tables.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.