Problems sorting rendered columns
Problems sorting rendered columns
airandfingers
Posts: 30Questions: 0Answers: 0
I'm having trouble sorting on some of the columns that I've configured to render modified text.
See
http://live.datatables.net/alakuc/3/edit
Note that the first column (time) cannot be sorted on, while the second column can be.
Any help would be appreciated.
-Aaron
See
http://live.datatables.net/alakuc/3/edit
Note that the first column (time) cannot be sorted on, while the second column can be.
Any help would be appreciated.
-Aaron
This discussion has been closed.
Replies
[best solution] this fixes it by telling DataTables to use the original pre-Rendered value
[code] 'aoColumnDefs': [
{
'fnRender': function(o)
{
return dateDiff(o.aData[o.iDataColumn]);
},
'bUseRendered': false,
'aTargets': [0]
}
][/code]
[alternate solution] this fixes it by changing the sType:
[code] 'aoColumnDefs': [
{
'fnRender': function(o)
{
return dateDiff(o.aData[o.iDataColumn]);
},
'sType': 'string',
'aTargets': [0]
}
][/code]
however, string sorting won't necessarily sort the way you intend, so you might have to write a custom sorter to make it work properly - or output your fnRender string in such a way that it sorts properly.
one possible output format would be something like:
+0000d 18:00:00
+0001d 00:00:00
http://www.datatables.net/ref
bUseRendered
sType
I was setting bUseRendered as a first-level setting of dataTables, instead of as a member of the aoColumnDefs entry. Your correct use of bUseRendered fixes this problem for me. Thanks!
I see that bUseRendered is listed as an "Init option - columns". I'll make sure to check that column of the reference before using any settings.
-Aaron