Replies: 1
Hi there!
I would like to fix the first column (disable it from sorting with the rest of the columns).
The FixedColumns option is not what I am looking for as this just freezes the column when scrolling.
I used this code to disable sorting on the first column:
"columnDefs": [
{ "orderable": false, "targets": 0 }
]
However, this option just takes away the sorting button on top.
What I really want is explained on this page:
https://datatables.net/examples/api/counter_columns.html
To do this I tried the following code, but unfortunately this also doens’t work:
$(document).ready(function() {
var t = $('#example').DataTable( {
"columnDefs": [ {
"searchable": false,
"orderable": false,
"targets": 0
} ],
"order": [[ 1, 'asc' ]]
;
t.on( 'draw.dt', function () {
var PageInfo = $('#example').DataTable().page.info();
t.column(0, { page: 'current' }).nodes().each( function (cell, i) {
cell.innerHTML = i + 1 + PageInfo.start;
} );
} );
} );
Does anyone have a solution to get this working?