≡
×
Plus
Manual
Examples
Reference
Download
Blog
Community
Support
sort asc on class
sort asc on class
tuurtnt@hotmail.com
Posts: 7
Questions: 0
Answers: 0
September 2010
edited September 2010
in
General
Is it possible to add a classname (defaultsort) to a TH, so that datatables always sorts on this column?
Replies
allan
Posts: 65,820
Questions: 1
Answers: 10,951
Site admin
September 2010
Something like this should do the trick:
[code]
$('#example').dataTable({
"aaSorting": [[$('#example thead tr th').index($('th.defaultsort')[0]), 'asc']]
});
[/code]
Allan
tuurtnt@hotmail.com
Posts: 7
Questions: 0
Answers: 0
September 2010
thanks! is it also possible to do this within:
this doesn't work...
[code]
"aoColumnDefs": [
{
"aaSorting": [[$('#DTsortable thead tr th').index($('th.sortdefault')[0]), 'asc']],
"aTargets": [ 'sortdefault' ]
}
]
[/code]
allan
Posts: 65,820
Questions: 1
Answers: 10,951
Site admin
September 2010
There is no
aaSorting
option for a column definition ( http://datatables.net/usage/columns ) - so no that wouldn't work.
aaSorting
is a general initialisation option, not a column specific one (since it can span multiple columns).
Allan
tuurtnt@hotmail.com
Posts: 7
Questions: 0
Answers: 0
September 2010
ok thanks!
This discussion has been closed.
Replies
[code]
$('#example').dataTable({
"aaSorting": [[$('#example thead tr th').index($('th.defaultsort')[0]), 'asc']]
});
[/code]
Allan
this doesn't work...
[code]
"aoColumnDefs": [
{
"aaSorting": [[$('#DTsortable thead tr th').index($('th.sortdefault')[0]), 'asc']],
"aTargets": [ 'sortdefault' ]
}
]
[/code]
Allan