Enable Custom DataTable Sorting

DataTables will reset the table to the first page after sorting by default. As there is no way to override this behavior, this module will remove the DataTable sorting event handlers and set its own, which will keep the table to the current page. This module will also set a sort parameter to the URL on sorting change but will not parse it during initialization. This must happen from the module that initializes the table.

Important: This method will remove the click event from the "th.sorting" elements, so bind extra "click" events after enabling the custom-sorting extension (on init.dt event).

Events

// Add custom callback once the column sorting was changed (the "info" object contains the column index,
// column name and sort direction: {index, name, direction}).
$('#datatable-instance').on('datatable_custom_sorting:change', function(event, info) {...});
Source: