Datatables not using data-order
Datatables not using data-order
We have an internal system built with DataTables and Bootstrap - and everything works perfectly except sort of date columns (DD-MM-YYYY format). We have chosen to use the option to add 'data-order' (date in numeric format) to each row, but we can't get it to work :-/
Is it posible to check, if DataTables is using the 'data-order' or the column data for sorting?
It's working on the live test system with some of our data:
http://live.datatables.net/woxeneju/1/edit
This question has an accepted answers - jump to answer
Answers
Your example appears to work for me unless I'm missing something - it is shown in the following order when I click on the
name
column:Allan
Hi Allan, and thanks for your fast reply.
"It's working on the live test system with some of our data...", but I'm looking for an option to check/debug if our internally system is using the 'data-order' or not.
Do you know how I can achieve this?
Sorry - I missed that bit. To check use
data()
and check what the data structure that DataTables has for the rows.Allan
Hi Allan, with your help I achieved to come one step closer to understand why my sorting didn't work, but it also give me some new problems. If I remove the following the date sorting works:
Can you suggest another solution or have I found a error in dataTables?
Updated live test:
http://live.datatables.net/woxeneju/6/edit?html,js,console,output
You could use
data[i][3]
and not define the column data into objects.Otherwise you'd need to use a statement such as the following for the age column:
Its a bit messy, but that is basically what DataTables does internally. I will look to see if the automatic detection can be improved when using objects.
Allan
Thanks Allan, I will be using the
data[i][3]
notation, but it will require some extra comments in my code :-PKeep up the good work.