Even doing "orderable": false, "targets": 0 doesnt stop the first collum for being ordered
Even doing "orderable": false, "targets": 0 doesnt stop the first collum for being ordered
User123456
Posts: 57Questions: 15Answers: 0
The command:
$(document).ready(function() {
var table = $('#publicationTable').DataTable( {
...
"columnDefs": [
{ "orderable": false, "targets": 0 },
{ "orderable": false, "targets": 7 },
],
...
And the table structure:
<table id="publicationTable" class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th></th>
<th>Título</th>
<th>Tipo</th>
<th>Ano</th>
<th>Competência</th>
<th>Razão Social</th>
<th>Empregado</th>
<th></th>
</tr>
</thead>
</table>
I'm Still being able to sort the first collum, but not the last. Why?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Are you saying that you can click the header of the first column and change the order?
Or that the column is ordered when the table is loaded?
If the second then you need to set the
order
to order the table the way you want. It defaults to ordering the first column by ascending.Kevin
The first option @kthorngren. I can click the header of the first collum and change order. Even using the code above.
I copied your code into this test case and it works. Meaning clicking on the first column does not change the order.
Maybe you can share more of your code or provide a link or test case showing the issue.
Kevin
@kthorngren, the bin isn't working for me.
See the image for a better comprehension. Using this same code it's possible to order the table clicking.
This is the code to initialize the datatables plugin:
@kthorngren, I don't know why, but I realized now that, its not sorting/ordering. It's clickabe but it's not ordering the first collum. I can click but nothing happens.
If I click in the header of other collum (except for 0 and 7) its ordered and the first icon disappear. Strange, is there a way to fix this?
Like I said the default order of the table is the first column ascending. Reading the
columns.orderable
docs it states:The upward arrow is there because that is the column that is being sorted. If you want to change this you can use
order
to select the column or columns you prefer to have ordered on initialization.Kevin