Sort Data Type based on classnames
Sort Data Type based on classnames
ZenCocoon
Posts: 10Questions: 0Answers: 0
Hi,
New to DataTable I'm wondering if it's possible to give the data type of a column using classnames in it's header. I've seen the "aoColumns" option and type detection but would rather use something more generic that would simply check for classname to force the data type of a column.
Any help or path to dig through will be greatly appreciated.
P.S. : Thanks for this amazing library, really useful!
New to DataTable I'm wondering if it's possible to give the data type of a column using classnames in it's header. I've seen the "aoColumns" option and type detection but would rather use something more generic that would simply check for classname to force the data type of a column.
Any help or path to dig through will be greatly appreciated.
P.S. : Thanks for this amazing library, really useful!
This discussion has been closed.
Replies
> P.S. : Thanks for this amazing library, really useful!
Thanks :-)
Allan
That's impressively fast! I really appreciate it.
[code]
"aoColumnDefs": [ {
"sType": "numeric",
"aTargets": ["sort-as-numeric"]
}
]
[/code]
and all looks great at first sight, however, clicking to header of a numeric column doesn't reorder anymore, is that an expected behavior ? Did I missed something ?
I suspect what you might need to do is use a sorting plug-in, given that is isn't being pick dup automatically: http://datatables.net/plug-ins/sorting .
Allan
Shall I rather use the HTML type ? or a sorting plugin is required ?
The surprising thing is that it work just nice when the table is first loaded.
Thanks Allan,
- Seb
http://datatables.net/plug-ins/sorting#numbers_html
http://datatables.net/plug-ins/type-detection#numbers_html
That will allow DataTables to automatically detect this column as numeric and sorting it accordingly. You won't need to specify anything in aoColumnDefs :-)
Allan