How to clear search on a table sort?

How to clear search on a table sort?

samullensamullen Posts: 1Questions: 1Answers: 0

We are using Datatables with the "serverSide" setting. Pagination, sorting, and searching all work swimmingly by themselves, but trying to sort on a column after a search has been performed causes an issue on the backend (our search engine defaults to search ranks and also aliases table names).

The current solution I have is to clear out the search field (i.e. reset the search) on a column reorder:

    .on("order.dt", function(e) {
      $(this).DataTable().search("");
    })

That works...okay, but the reorder only takes effect on the second column reorder. It seems data reordering triggers both an "order.dt" and a "search.dt" events.

Is there a way I can, on a reorder, clear the search before sending the reorder to the backend?

Alternatively, is there a way to determine if it's a reorder and not an actual search?

Thanks!
Samuel

This discussion has been closed.