help datatable error destoy

0

Good I have a problem with my table, at the moment I call it to load (when I insert something I call the table to update it at the moment), it marks me as an error or warning, I have to destroy the table and rebuild it but I do not know how to do that, it tells me this:

for(var i=0; i<data.length; i++)
    {

         html+= '<tr><td class="center">'+data[i].fecha_registro+
            '</td><td class="center">'+dias+
            '</td><td class="center">'+data[i].nombre+
            '</td><td class="center">'+data[i].modelo+
            '</td><td class="center" data-id="'+data[i].id+'"><span data-id="'+data[i].id+'"class="label ' + colorear(data[i].ser,'col_ser') + '">'+data[i].ser+
            '</span></td><td class="center"><span data-id="'+data[i].id+'" data-auto="'+data[i].modelo+'" class="label ' + colorear(data[i].se,'col_se') +'">'+data[i].se+
            '</span></td></tr>';
    }
    $('#body_valuaciones').html(html);

    $('#table_valuaciones').dataTable( {

                    "bPaginate":false,
                     "bAutoWidth": true,

    } );
    $('.dataTables_filter input').each(function() {
            $(this).attr("placeholder", "Buscar");
        });
    
asked by Juan Jose 25.10.2018 в 22:17
source

1 answer

0

If the table already exists, you can do this:

var table = $('#table_valuaciones').DataTable();

table.destroy();

$('#table_valuaciones').dataTable( {

                "bPaginate":false,
                 "bAutoWidth": true,

} );
    
answered by 25.10.2018 в 22:28