How are sorting server side?
How are sorting server side?
Siggi
Posts: 3Questions: 2Answers: 0
hey
how can i sort columns by timestamp?
i use in my code the return display and timestamp
->editColumn('start', function ($data) {
if ($data->start->timestamp < $data->end->timestamp && $data->start->format('Y') == $data->end->format('Y')) {
$dateFormat = $data->start->format('d.m') . ' - ' . $data->end->format('d.m.Y');
} elseif ($data->start->timestamp < $data->end->timestamp) {
$dateFormat = $data->start->format('d.m.Y') . ' - ' . $data->end->format('d.m.Y');
} else {
$dateFormat = $data->start->format('d.m.Y');
}
return [
'display' => e($dateFormat),
'timestamp' => $data->end->timestamp
];
})
my javascript code is
$('#dataTableEvents').dataTable({
processing: true,
serverSide: true,
ajax: '/events/all-events',
columns: [
{data: 'action'},
{data: 'name'},
{data: 'start.display', sort: 'start.timestamp'},
{data: 'end'},
],
order: [[2, 'desc'], [3, 'desc']],
columnDefs: [
{
targets: 0,
orderable: false,
searchable: false,
width: "58px"
}
]
});
the result is
31.12.2018 - 01.01.2019
31.10 - 31.10.2018
31.10 - 31.10.2016
31.10 - 31.10.2016
31.08 - 31.08.2018
31.08 - 31.08.2017
31.05 - 31.05.2019
30.08.2019
i can the html 5 data-order with timestamp in the td but with server side not working
thx for help
This discussion has been closed.
Answers
Okay it works when i delete
What is
->editColumn('start', function ($data) {
? I don't think that's part of a script we publish?Allan