Jquery Datatables column rendering and sorting
I think I got it. I just had to tell the render function to only operate on "display" types:
{ "data":"created_at", "name":"date", "visible":true, "title":"Date Created", "render": function(data, type, full, meta){ if(type == "display"){ var date = new Date(data); var options = {year: "numeric", month: "long", day: "numeric"}; return date.toLocaleDateString('en-US', options); } return data; }},
Well if it is a server-side datatable, what you can do is edit a json just before it is passedlike in the beginning of ssp.class.php in the new datatables (tell me if you are using the old one)
NOTE: in the new datatables, it is an inbuilt function called formatter that does the same but you can use custom function like this
if ($j == 6) { if ($data[$i][$columns[$j]['db']] == 1) { $data[$i][$columns[$j]['db']] = '<label class="btn-danger disabled btn">Stopped</label>'; } else { $data[$i][$columns[$j]['db']] = '<label class="btn-success disabled btn">Running</label>'; }
here i am simply editing a 0 and 1 in my db to a Label Stopped and Running
you can do something like parse_date and store a reformatted one