I Can't search the date, even rendering the column in the client side, what is wrong in my code?
I Can't search the date, even rendering the column in the client side, what is wrong in my code?
kenionatan
Posts: 4Questions: 2Answers: 0
Server side:
<?php
$table = 'invoices';
$primaryKey = 'doc';
$columns = array(
array( 'db' => 'doc', 'dt' => 0 ),
array( 'db' => 'serial_doc', 'dt' => 1 ),
array( 'db' => 'register', 'dt' => 2 ),
array( 'db' => 'issue_date', 'dt' => 3 )
);
Client side:
$(document).ready(function(){
var table = $('#example').DataTable({
"processing": true,
"serverSide": true,
"ajax": {
"url": "http://localhost:911/portal_fornecedor/portal/processing_month.php",
},
columns: [
{"data": 0},
{"data": 1},
{"data": 2},
{
data: 3,
render: function(data, type, row){
if(type === "sort" || type === 'type'){
return data;
}
return moment(data).format("DD/MM/YYYY");
}
}
]
});
});
The date is displayed in this format: DD/MM/YY, but only is searchable in the original format: YYYY-MM-DD
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
You have
serverSide": true,
which requires the server to perform the search. You will need to convert theDD/MM/YY
formatted search term to something that works with your backend data.Kevin
using the serverSide: true, what can I do so I can sort and search formatted date (DD/MM/YYYY) ?