Can't clear or update datatable

Can't clear or update datatable

bstras21bstras21 Posts: 7Questions: 2Answers: 0

Hello, I have a datatable working fine initially then I try a custom search and I can't get the data into the table. I see my query to the server is good, my response from the server is good but the table won't update. I can't even clear my table

var table = $(me.element).DataTable({
iDisplayLength: 50,
responsive: true,
processing: true,
serverSide: true,
searching: false,
bLengthChange: false,
ajax: {
url: me.url,
dataType: 'json',
cache:false,
type: 'GET',
data: function ( d ) {
$.extend( d, me.data);
d.supersearch = $('.simply-filter').val();
}
},
columns: me.columns,
columnDefs: me.renderer
});

    function gridSearch(element){
        var table2 = $(element).DataTable();
        table2.clear().draw();


    }

Does anyone know how I can clear the table and repopulate it with the new query result?

Answers

  • bstras21bstras21 Posts: 7Questions: 2Answers: 0

    Sorry here is the code reformatted:

           var table = $(me.element).DataTable({
            iDisplayLength: 50,
            responsive: true,
            processing: true,
            serverSide: true,
            searching: false,
            bLengthChange: false,
             ajax: {
                url: me.url,
                dataType: 'json',
                cache:false,
                type: 'GET',
                data: function ( d ) {
                    $.extend( d, me.data);
                    d.supersearch = $('.simply-filter').val();
                }
            },
            columns: me.columns,
            columnDefs: me.renderer
        });
    
    
    
        function gridSearch(element){
            var table2 = $(element).DataTable();
            table2.clear().draw();
    
        }
    
  • bstras21bstras21 Posts: 7Questions: 2Answers: 0

    I seem to always figure it out after I post. Anyway I am using a custom php query and I wasn't returning the draw from the server.

This discussion has been closed.