Reset Datatable

Reset Datatable

jjcfidalgo@gmail.comjjcfidalgo@gmail.com Posts: 11Questions: 8Answers: 0

I tryed to reset datatable by doing this, but didn't works, why?
$('#linhasPorIntroduzir').on('show.bs.modal', function (event) {

      var mystamp=$('#myStamp').val();
      if (mystamp!='')
      {
        $('#equipamentos').DataTable().clear().draw();;
        $('#equipamentos').DataTable().destroy();
        $("#equipamentos thead").html('');
        $("#equipamentos tbody").html('');
        $('#equipamentos').empty();

        var table=$('#equipamentos').DataTable({
            'order': [],
            paging: false,
            'ordering': false,
            'bPaginate': false,
            'language': {
                'sEmptyTable': 'Nenhum registro encontrado',
                'sLengthMenu': 'Mostrar _MENU_ registos',
                'sProcessing': 'A processar...',
                'sZeroRecords': 'Não foram encontrados resultados',
                'sInfo': 'Mostrando de _START_ até _END_ de _TOTAL_ registos',
                'sInfoEmpty': 'Mostrando de 0 até 0 de 0 registos',
                'sInfoPostFix': '',
                'sInfoFiltered': "(filtrado de _MAX_ registos no total)",
                'sSearch': "Procurar:",
                'sUrl': '',
                'oPaginate': {
                    'sFirst': 'Primeiro',
                    'sPrevious': 'Anterior',
                    'sNext': 'Seguinte',
                    'sLast': 'Último'
                },
                'oAria': {
                    'sSortDescending': ': Ordenar colunas de forma descendente',
                    'sSortAscending': ': Ordenar colunas de forma ascendente',
                }
            }
        });
        var paras = {};
        paras.id='ebiseries';
        paras.stamporigem=$("#ebistamplote").val();
        paras.stampebi=mystamp;
        jQuery.ajax({
            type: 'POST',
            async: false,
            url: '../api/code/run',
            data:  JSON.stringify(paras),
            contentType: 'application/json'
        })
        .fail(function (jqXHR, textStatus, errorThrown) {
        if (jqXHR.responseJSON && jqXHR.responseJSON.Message)
        throw jqXHR.responseJSON.Message;
        })
        .done(function (data, textStatus, jqXHR) {
           $('#nseries').empty()
           var obj = jQuery.parseJSON( data );
           table.row.add(obj).draw();

        }); 
      }  
});

Answers

  • allanallan Posts: 61,627Questions: 1Answers: 10,090 Site admin

    Not sure what you mean by "reset". Do you mean empty it of data, reset the paging / filtering, or something else? If you can link to a test case showing the issue, that would be really useful.

    Allan

Sign In or Register to comment.