Custom Sort for DataTable Column Based on Another Property
Custom Sort for DataTable Column Based on Another Property

In my DataTable, one column has custom render logic, but its Sort has to happen directly based on the "reminderInfo" row property. This is not working.
"columns" : [ {
"data" : "reminderInfo" /* also tried "sort" : "reminderInfo" */
"render": function (data, type, row) {
if(row.reminderCount != null) {
return '<div class="reminder"><span class="fa-layers fa-fw fa-lg reminder-counter"><i class="fas fa-bell"></i><span class="fa-layers-counter">' + row.reminderCount + '</span></span>'
+'<div class="reminder-date">' + row.formattedLastReminderDate + '</div></div>';
} else {
return '';
}
}
}
],
The sorting does not follow the row's straight reminderInfo property.
This discussion has been closed.
Answers
If you want sort to be different to display, then you need to handle that in your
columns.render
function, something like this: http://live.datatables.net/tolezupe/2/editColin
The example provided doesn't have any custom sorting.
We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin