Column not being sorted according to new format
Column not being sorted according to new format
Hi,
I am using server side processing to retrieve values for the columns.
I have a date field in the format of DD/MM/YYYY , however, I format that into a string server side, so that it reads only "YYYY" in string format.
However, when I click on the column header after the table is finished loading, it sorts according to the original DD/MM/YYYY value, even though in the column, it displays only YYYY e.g. 2014.
How can I fix this ?
Server side columns array section:
.
.
.
array(
'db' => 'datecreated',
'dt' => 'new_d',
'formatter' => function($d, $row)
{
// DD/MM/YYYY HH:MM:SS
$newdateyear = substr(substr($d,0,10),6,4);
return $newdateyear;
}),
.
.
.
Client side columns section:
\"columns\":[
.
.
.
{"data": "new_d","bSortable": true },
.
.
.
],
I just want it to be sorted asc and desc correctly based on the new formatted values e.g. asc : 2014, 2015 ... desc : 2015, 2014 ...
Please help
Answers
Nevermind, the sorting obviously happens server side.