Quantcast
Viewing all articles
Browse latest Browse all 82034

How to clear all Filter/Sorts/Pagination (without reinitializing the table from scratch)

is there an easy way to reset a DataTable to its original state by removing all Filters/Sorts/Pagination the user may have applied? I want to return to the "blank state."

I posted previously that I found a way to do it by doing clear/destroy and then reinitialization,

var activeRequestsTable = $('#activeRequestsTable').DataTable();
activeRequestsTable.state.clear();
activeRequestsTable.destroy();
    $('#activeRequestsTable').DataTable({
           "ajax": {
            url: myUrl, 
            dataSrc: 'activeRequests',
            type: 'POST',
            //etc.
        }
    },
    "columns": [ .. ]
    });

But that is a performance hit because I'm refetching data for the table. I have all the table data, I just need to reset the state quickly back to blank.


Viewing all articles
Browse latest Browse all 82034

Trending Articles