I have a code, which when starting, creates a table using dataTable . The data in this table comes from my MySQL database. I am not sure how my records are sorted, if I am not mistaken it is coming from the Id, but I need it to be sorted by the Date of each record.
In MySQL and the codeigniter model (which I'm using) I know how to do, but when not using dataTable . With him, I do not know how. My code as I said before is in CodeIgniter .
The part that makes this table looks like this:
var oTable = $('#tabletools').dataTable({
"sProcessing": '<?= $this->lang->line("datatable_process"); ?>',
"bProcessing": true,
"bServerSide": true,
"bAutoWidth": true,
"sAjaxSource": "<?php echo base_url() . $caminho; ?>",
"fnDrawCallback": function (oSettings) {
$("td:nth-child(1)").addClass('hidden-md hidden-sm hidden-xs');
$("th:nth-child(1)").addClass('hidden-md hidden-sm hidden-xs');
$("td:nth-child(4)").addClass('hidden-md hidden-sm hidden-xs');
$("th:nth-child(4)").addClass('hidden-md hidden-sm hidden-xs');
$("td:nth-child(5)").addClass('hidden-md hidden-sm hidden-xs');
$("th:nth-child(5)").addClass('hidden-md hidden-sm hidden-xs');
$("td:nth-child(6)").addClass('hidden-md hidden-sm hidden-xs');
$("th:nth-child(6)").addClass('hidden-md hidden-sm hidden-xs');
$("td:nth-child(7)").addClass('hidden-md hidden-sm hidden-xs');
$("th:nth-child(7)").addClass('hidden-md hidden-sm hidden-xs');
$("[rel=tooltip]").tooltip();
},
"oLanguage": {
"sProcessing": "<?= $this->lang->line("datatable_process"); ?>",
"sZeroRecords": "<?= $this->lang->line("datatable_records"); ?>",
"sInfo": "<?= $this->lang->line("datatable_info"); ?>",
"sInfoEmpty": "<?= $this->lang->line("datatable_empty"); ?>",
"sInfoFiltered": "<?= $this->lang->line("datatable_filter"); ?>",
"sInfoPostFix": "",
"sUrl": "",
"oPaginate": {
"sFirst": "<?= $this->lang->line("datatable_first"); ?>",
"sPrevious": "<?= $this->lang->line("datatable_previous"); ?>",
"sNext": "<?= $this->lang->line("datatable_next"); ?>",
"sLast": "<?= $this->lang->line("datatable_last"); ?>"
}
},
"fnInitComplete": function (oSettings, json) {
$(this).closest('#dt_table_tools_wrapper').find('.DTTT.btn-group').addClass('table_tools_group').children('a.btn').each(function () {
$(this).addClass('btn-sm btn-default');
});
$("td:nth-child(1)").addClass('hidden-md hidden-sm hidden-xs');
$("th:nth-child(1)").addClass('hidden-md hidden-sm hidden-xs');
$("td:nth-child(4)").addClass('hidden-md hidden-sm hidden-xs');
$("th:nth-child(4)").addClass('hidden-md hidden-sm hidden-xs');
$("td:nth-child(5)").addClass('hidden-md hidden-sm hidden-xs');
$("th:nth-child(5)").addClass('hidden-md hidden-sm hidden-xs');
$("td:nth-child(6)").addClass('hidden-md hidden-sm hidden-xs');
$("th:nth-child(6)").addClass('hidden-md hidden-sm hidden-xs');
$("td:nth-child(7)").addClass('hidden-md hidden-sm hidden-xs');
$("th:nth-child(7)").addClass('hidden-md hidden-sm hidden-xs');
},
'fnServerData': function (sSource, aoData, fnCallback) {
aoData.push({name: '<?= $this->security->get_csrf_token_name() ?>', value: '<?= $this->security->get_csrf_hash() ?>'});
aoData.push({name: "sSearch_1", value: iMin});
aoData.push({name: "sSearch_2", value: iMax});
$.ajax
({
'dataType': 'json',
'type': 'POST',
'url': sSource,
'data': aoData,
'success': fnCallback
});
}
});