Sorting Value for cell in a nested javascript object data source
Sorting Value for cell in a nested javascript object data source
The jquery datatables plugin v1.10 is able to enhance an already existing html-table and is able to read a special data-order
tag for providing a different sorting value, as seen here:
<tr>
<td>System Architect</td>
<td data-order="1303686000">Mon 25th Apr 11</td>
<td data-order="320800">$320,800/y</td>
</tr>
This works fine - we are trying to achieve the same with a nested javascript object as source, like so
{
"jobDescription":"System Architect",
"startDate": {
"display": "Mon 25th Apr 11",
"sort": 1303686000
},
"salary": {
"display": "$320,800/y",
"sort": 320800
}
},
However, it does not seem to work this way. Is there an already existing way to provide the sorting value or do we have to implement our own?
Thank you in advance.
This question has an accepted answers - jump to answer
Answers
That will work, have a look at the orthogonal data section of the manual and also the
columns.data
property documentation.Allan
Ah, it does work, if the
type
is manually set to "num". From the orthogonal data page, I was under the impression, that thetype
-parameter is arender
option. Maybe this should be added to the manual.For future reference, here is an example
Thanks for the help, Allan!
You want to avoid setting the
type
if you can and just let DataTables detect it automatically. The issue was that thedisplay
property was being used for type detection in your example - you want to tell it to usesort
- updated example.Allan