Disable sorting
Disable sorting
HI guys!
I have my datatable with two colums. In the first column I store some names. Now, I don't want the names to be automatically sorted alphabetically. I tried to disable sorting with the following code:
[code]
$('#jTable').dataTable(
{
"aoColumns": [{ "bSortable": false },{ "bSortable": false }]
} );
[/code]
But this also doesn't work. As soon as a new entry is inserted, it is positioned in alphabetic order.
Can anyone give me a hint please?
Thanks in advance.
I have my datatable with two colums. In the first column I store some names. Now, I don't want the names to be automatically sorted alphabetically. I tried to disable sorting with the following code:
[code]
$('#jTable').dataTable(
{
"aoColumns": [{ "bSortable": false },{ "bSortable": false }]
} );
[/code]
But this also doesn't work. As soon as a new entry is inserted, it is positioned in alphabetic order.
Can anyone give me a hint please?
Thanks in advance.
This discussion has been closed.
Replies
First, try setting "bSort" to false. (http://datatables.net/usage/features#bSort )
Note that this will disable sorting all around, so there is no need to disable it on individual columns.
[code]
$('#jTable').dataTable(
{
"bSort" : false
} );
[/code]
Second, try setting aaSorting to empty. (http://datatables.net/usage/options#aaSorting )
Note that this would be good to try if you still want to allow some other column(s) to be sortable.
[code]
$('#jTable').dataTable(
{
"aaSorting" : [[]]
} );
[/code]
Let us know if either works for you.
Hope it helps,
Chris.
[code]
// Using aoColumns
$(document).ready(function() {
$('#example').dataTable( {
"aoColumns": [
null,
null,
{ "bSortable": false }
] } );
} );
[/code]
Which will disable the sorting on the last column but not the first two.
Allan