I have a table that looks like this:
JS:
"columns": [
{
"data": 0,
"iDataSort" : 0
},
{
"data": 1,
"iDataSort" : 1,
"render": function ( data, type, row ) {
var returnString = data;
if( row[2] !== null && row[2].length > 0){
returnString += "<ul>";
for( var alternativeTitle in row[2] ){
returnString += "<li>" + row[2][alternativeTitle] + "</li>"
}
returnString += "</ul>"
}
return returnString;
}
},
{
"iDataSort" : 3,
"data": 3
},
{
"iDataSort" : 4,
"data": 4
},
{
"data":null,
"bSearchable": false,
"bSortable": false,
"sClass": "center",
"render": function (row) {
return '<a href"#">Edit</a>';
}
}
],
HTML :
<table>
<thead>
<tr role="row" class="heading">
<th>
Id#
</th>
<th>
Original title (alternative titles)
</th>
<th>
Year of production
</th>
<th>
Country
</th>
<th>
Actions
</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
As you can see, I provide a 5 column array as a data source (id, title, alternative titles[], year of production and country) but I render them differently (original title and alternative titles go in the same column while the last column is for action buttons). Now I want to disable sorting on the last column (as that would make no sense, because its reserved for buttons) but when I put "bSortable": false on the last column with buttons, it affects the last column visually, but also affects the GET sent by datatables, in effect when I click on "sort by country", nothing happens, because datatables sends "bSortable_4 = false to the server.
I want to be able to sort on the Country column, but to disable sorting on the Actions column. How to achieve this?