0
Friends, I am having trouble sorting a table with Datatable plugin and I do an SQL query already ordered by a field and when it presents the table with the plugin it reorders otherwise and I have tried several unsuccessful ways to solve it.
SQL
$sql = "SELECT * FROM $this->table ORDER BY date(data_cadastro) DESC";
Datatable
var tabela = $('#Compras').dataTable( {
"aoColumns": [ null,null,null,null,null,{ "bSortable": false },{ "bSortable": false },{ "bSortable": false },{ "bSortable": false },null,{ "bSortable": false } ],
"oLanguage": {
"sEmptyTable": "Nenhum registro encontrado",
"sInfo": "Mostrando de _START_ até _END_ de _TOTAL_ registros",
"sInfoEmpty": "Mostrando 0 até 0 de 0 registros",
"sInfoFiltered": "(Filtrados de _MAX_ registros)",
"sInfoPostFix": "",
"sInfoThousands": ".",
"sLengthMenu": "_MENU_ resultados por página",
"sLoadingRecords": "Carregando...",
"sProcessing": "Processando...",
"sZeroRecords": "Nenhum registro encontrado",
"sSearch": "Pesquisar",
"oPaginate": {
"sNext": "Próximo",
"sPrevious": "Anterior",
"sFirst": "Primeiro",
"sLast": "Último"
}
},
"oAria": {
"sSortAscending": ": Ordenar colunas de forma ascendente",
"sSortDescending": ": Ordenar colunas de forma descendente"
}
});
})
PHP
<?=date("d/m/Y", strtotime($x->data_cadastro)) ?>
Sql return:
14/03/2018
14/03/2018
14/03/2018
13/03/2018
12/03/2018
Table result:
14/03/2018
14/03/2018
13/03/2018
12/03/2018
14/03/2018