Ali Zia
Ali Zia

Reputation: 3875

How can I ignore the search field from jquery datatable bstatesave

I want to save all the fields in bstatesave except for search

This is my code

$('#dataTable').DataTable({
    columnDefs: [
        {orderable: false, targets: -1}
    ],
    "bStateSave": true
});

I tried several ways but either search re-appears of jquery datatable doesn't work. I want it to work exactly like this, just don't the search in it. How can I achieve this?

Upvotes: 1

Views: 288

Answers (1)

gaetanoM
gaetanoM

Reputation: 42054

From the documentation you can use the following callback:

stateSaveParams( settings, data ): allows modification of the parameters to be saved for the DataTables state saving

$('#dataTable').DataTable({
    columnDefs: [{
        orderable: false, targets: -1
    }],
    "bStateSave": true,
    "stateSaveParams": function (settings, data) {
        data.search.search = "";
    }
});

Upvotes: 1

Related Questions