onlinecode

Datatable disable sorting on particular column example

Datatable disable sorting on particular column example

In this post we will give you information about Datatable disable sorting on particular column example. Hear we will give you detail about Datatable disable sorting on particular column exampleAnd how to use it also give you demo for it if it is necessary.

If you want to remove sorting arrows or disable sorting on specific columns in datatables library than you can do it using columnDefs. we can simple disable ordering arrows from table in data tables js. even you are using with php, laravel, codeigniter, vue js etc. we can disable particular column sorting like one column, first column, last column, specific index.

Datatable library makes very simple pagination, sorting and searching. Datatables by default provide all function by default like ordering, pagination, listing searching for all table column. But if you want to disable ordering, search or visibility for specific column then you can use columnDefs.

columnDefs provide to set parameter allows you to assign specific options to columns in data tables.

You can see sample code of columnDefs:

'columnDefs': [ {

'targets': [1,3], /* column index */

'orderable': false, /* true or false */

}]

Example:

Also see:Laravel 5.7 JQuery Form Validation Example

$(document).ready(function(){

$('#empTable').DataTable({

'processing': true,

'serverSide': true,

'serverMethod': 'POST',

'ajax': {

'url':'/ajax/users.php'

},

'columns': [

{ data: 'id' }, /* index = 0 */

{ data: 'name' }, /* index = 1 */

{ data: 'email' }, /* index = 2 */

{ data: 'gender' }, /* index = 3 */

{ data: 'city' } /* index = 4 */

],

'columnDefs': [ {

'targets': [1,2], /* column index */

'orderable': false, /* true or false */

}]

});

});

I hope it can help you…

Hope this code and post will helped you for implement Datatable disable sorting on particular column example. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Exit mobile version