Data Render, but i can't sort it.
Data Render, but i can't sort it.

Hey, guys,
sorry for my bad english, but I have in problem and I can't manage to solve it.
I use the following code:
{ "data": null, "render": function ( data, type, row ) {
let sdate1 = new Date ();
let sdate2 = new Date (data.dexpired);
let smilli1 = sdate1.getTime();
let smilli2 = sdate2.getTime();
if (smilli2 > smilli1 && data.dconfirmed == null && data.ddeleted == null) {
return 'Open';
} else if (smilli2 < smilli1 && data.dconfirmed == null && data.ddeleted == null) {
return 'Overdue';
} else if (data.dconfirmed != null && data.ddeleted == null) {
return 'Confirmed';
} else if (data.ddeleted != null) {
return 'Closed';
}
return 'Error!';
}
},
Unfortunately, the columns can't be sorted or found afterwards.
I just want to fill a column and need the values from the data set only for the query.
Thank You.
Answers
I use Server-side processing btw.
If you're using
serverSide
then it's the responsibility of the server-side scripts to do the sorting and filtering. The protocol is discussed here. Also see examples here.You only need
serverSide
if you have 10ks or records - if less, just let the client take care of it.Cheers,
Colin
I thought the server side script only fetches the data?! All other columns can be sorted without problems. I think my problem is that I only return a string and no object "data". I use the server side script because I already have several 100k lines.
Nope, the server-side script does everything - sorting, filtering, paging, etc - it only returns the data to be displayed, in the order expected. If
serverSide
is enabled, the client only displays what's returned. It would be worth looking at the links I posted above,Colin
I have now integrated all this into the server script. Which makes me wonder, how can I sort a column that does not refer to a column header?
Or rather, how can I output text in a field that is not related to the database?
Maybe: 'db' => null,?
With the code below we sort by dlocked. But not by the string that is returned.
It might be easier to do that on the client-side, with
columns.render
- you can change the data to be anything there.Colin