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,612
Questions: 1
Answers: 10,683
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,612
Questions: 1
Answers: 10,683
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
75.1K
All Categories
57
Priority support
24.6K
Free community support
1K
General
14
Announcements
2.6K
DataTables
127
DataTables 2
1.3K
DataTables 1.10
93
DataTables 1.9
35
DataTables 1.8
9
CloudTables
2.2K
Editor
2.8K
Extensions
20
AutoFill
314
Buttons
34
ColReorder
4
ColumnControl
33
DateTime
68
FixedColumns
51
FixedHeader
31
KeyTable
106
Responsive
24
RowReorder
43
Scroller
168
SearchBuilder
200
SearchPanes
107
Select
27
StateRestore
220
Bug reports
68
Feature requests
101
Plug-ins
11
Blog
73
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