Issue with checkbox column and ColumDefs
Issue with checkbox column and ColumDefs
Using the code below I have an issue with my checkbox column and ColumDefs. I have defined a checkbox column that is not a field in my db. I needed a checkbox to select rows. So I did what is illustrated in the examples with check-boxes and got what I needed done.
At some point I needed to make some columns non-sortable / non-orderable so I used the code. (Snippet below) Assuming I count from left to right my checkbox column should be at position 0 correct? my other columns 1,4,8 are non-orderable like I need them to be.
So I did this
Snippet with issue I think
"columnDefs": [ {
"targets": [ 0,1,4,8 ],
"orderable": false
} ],
The funny thing is this
- The table loads and targets 1,4,8 are non orderable whereas 0 can be ordered clicking the arrows
- As soon as I order by full name for example or any other orderable field for that matter. "targets": [ 0,1,4,8 ] are as I need them to be.
Any ideas why I need to use sort before the targets are set correctly?
This question has an accepted answers - jump to answer
Answers
You need to set a value for
order
as well. The default is to order on the first column.columns.orderable
effects the end user's ability to order the data, not the API's, hence the need for that.Allan
Thank you again for the solution
Add this to Datatables definition