Default sorting on colums with sortable:false
Default sorting on colums with sortable:false
I'm trying to have datatables to default sort by 2 columns. This all works great using: [code]"aaSorting": [ [5,'asc'], [0,'desc'] ],[/code] However I do not wish the user to be able to sort on the first column which is the id field but when I turn of sortable on that particular column using [code]"aoColumns":[
{
"bSortable": false,
}, [/code] the default sort also does not work. In short I only want to get rid of the sorting icons on top of the first column
{
"bSortable": false,
}, [/code] the default sort also does not work. In short I only want to get rid of the sorting icons on top of the first column
This discussion has been closed.
Replies
Allan
it really doesn't! two differences. I use multi-column sort and I use a json source for the table input.
Here is how I init the datatable.
[code]
$('.datatable').dataTable(
{
"sDom": "<'row'<'span6'l><'span6'f>r>t<'row'<'span6'i><'span6'p>>",
"sPaginationType": "bootstrap",
"oLanguage":
{
"sLengthMenu": "_MENU_ records per page"
},
"bServerSide": true,
"bDeferRender": true,
"aaSorting": [ [5,'asc'], [0,'desc'] ],
"sAjaxSource": "{{ URL::to('/admin/cars/data') }}",
"aoColumns":
[
{
"bSortable": false,
"sWidth": "50px",
"mRender": function ( data, type, row )
{
return '';
}
},
{
"sWidth": "50px",
"mRender": function ( data, type, row )
{
return '' + data + '';
}
},
{ },
{ },
{ },
{
"sWidth": "50px",
"mRender": function ( data, type, row )
{
if (data==0)
{
return '';
}
else if (data==1)
{
return '';
}
else { return ''; }
}
}
]
});
});
[/code]
I didn't know that before (please post a link to test cases in future so I'm not guessing at the configuration :-) ). With server-side processing enabled the sorting is done at the server. So I'm guessing that your server-side script is respecting `bSortable_{i}` . I guess you could put an override into your script that will check to see if it is the first draw or not, and if so, then do the sort anyway.
Allan
Is it possible to stop datatables from drawing the sort by button on the first column(this is the only thing that needs to happen) by a hook or overwrite function?
Allan