简体   繁体   中英

Prevent default order event on datatable

I have a server-side (ajax) processed datatable. I have enabled sorting on it but I want to implement my own custom sorting on it. I can capture the 'order.dt' event but I can't stop the event from making an ajax request (which reloads the data in the table). Here's the code:

$('#resultTable')
        .on('order.dt', function (e) {

            e.preventDefault();
            e.stopPropagation();


            //Custom sorting logic (without making ajax request)
            return false;    
        })
        .dataTable(
            //Code to make ajax request
        );

I disabled the sorting on datatables using ordering: false setting which creating the table.

I used a custom jQuery-based library TableSorter which gives the functionality of sorting the rows without firing an ajax request to update the page.

Hope it helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM