I wish to display a list of items in the order in which they are returned from my data source initially but still give the user the ability to sort on columns if they so wish.
In order to do this, i set the order
attribute to false
like so:
$('#table_id').DataTable({
order: false;
});
What this does however is hide the up/down caret symbols effectively disabling sorting. It seems that they only appear if you set order to an array of arrays (like [[1, "asc"]]
for example).
I have looked into the bSort
attribute but that doesnt seem to work..
Any ideas on how i can display a list in the order in which it es first?
Note: the datasource is a web service which returns a block of html that has the desired order of elements.
I wish to display a list of items in the order in which they are returned from my data source initially but still give the user the ability to sort on columns if they so wish.
In order to do this, i set the order
attribute to false
like so:
$('#table_id').DataTable({
order: false;
});
What this does however is hide the up/down caret symbols effectively disabling sorting. It seems that they only appear if you set order to an array of arrays (like [[1, "asc"]]
for example).
I have looked into the bSort
attribute but that doesnt seem to work..
Any ideas on how i can display a list in the order in which it es first?
Note: the datasource is a web service which returns a block of html that has the desired order of elements.
Share Improve this question edited Mar 7, 2019 at 8:38 user3307073 asked Mar 7, 2019 at 3:58 NotarasNotaras 7372 gold badges18 silver badges52 bronze badges2 Answers
Reset to default 6You need to set order
option, which defines initial sorting order (in form of array), to empty array, so that it will keep your data entries in their original order, while letting the users to sort the table afterwards:
$('#table_id').DataTable({
order: [];
});
For older version use this
$(document).ready( function() {
$('#example').dataTable({
/* Disable initial sort */
"aaSorting": []
});
})
newer versions
$(document).ready( function() {
$('#example').dataTable({
/* No ordering applied by DataTables during initialisation */
"order": []
});
})