DataTables
Advanced interaction
features for your tables.
Editor
Comprehensive editing
library for DataTables.
Manual
Download
Examples
Manual
Reference
Extensions
Plug-ins
Blog
Forums
Discussions
Sign In
Support
FAQs
Download
Purchase
≡
Show site navigation
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: 64,061
Questions: 1
Answers: 10,559
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: 64,061
Questions: 1
Answers: 10,559
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.
Sign In
·
Register
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Register
Quick Links
Categories
Recent Discussions
Unanswered
Categories
74.7K
All Categories
56
Priority support
24.3K
Free community support
1K
General
14
Announcements
2.6K
DataTables
99
DataTables 2
1.3K
DataTables 1.10
92
DataTables 1.9
35
DataTables 1.8
9
CloudTables
2.2K
Editor
2.8K
Extensions
20
AutoFill
312
Buttons
50
ColVis
30
DateTime
68
FixedColumns
50
FixedHeader
33
ColReorder
31
KeyTable
104
Responsive
23
RowReorder
43
Scroller
166
SearchBuilder
194
SearchPanes
107
Select
26
StateRestore
22
TableTools
220
Bug reports
67
Feature requests
100
Plug-ins
11
Blog
72
Web-site
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