order column by date
order column by date
within my columns function i render my mysql date to readable german version, like
31/08/2017<br>
23:10
how can i ensure the correct sorting by clicking the column head now ?
var thisDataTable = $('table.editorTable').DataTable({
ajax: {
url: '-admin/editor-alle_post-ssp.php',
type: 'POST',
},
order: [[1, 'desc' ]], /* default (idn) wenn nicht stateSave */
pageLength: 50,
stateSave: true,
colReorder: true,
columns: [
// Datum von
{ data: null,
className: '-text-right',
render: function (data, type, row) {
var output = data.alle_post.post_dup.replace(' - ', '<br>'); /* Zeilenumbruch vor Uhrzeit */
if(data.alle_post.post_dup.includes('0001')) { output = ''; }
return output;
},
editField: 'alle_post.post_dup',
},
}); // thisDataTable
This discussion has been closed.
Answers
Use the solution provided in this blog about sorting dates.
Kevin
thx. before i check your link. can we do the sorting in editor ajax tables like in normal datatables like
<td data-order="123">
this would be much easier.
You can use HTML 5 data attributes as described here and shown in this example.
Just to clarify....
The Editor doesn't show or sort any of the client data. That is performed by Datatables. The Editor is an added code that allow for editing the data.
Kevin