The order of the data in the table different with the data that's retrieved from database

The order of the data in the table different with the data that's retrieved from database

fradifradi Posts: 2Questions: 1Answers: 0

I have a table, and i need to make them sorted descending. i tried to change the models of my code, and when i dump the data that's being retrieved from db, it's showed me this result:

You can see from the picture, it's sorted descending by the column of 'no_surat'. But, however, i didn't understand why but the table that's showed in the actual page is sorted ascending.

Here's my code for my models:

public function get_surat_join()
{
return $this->db->table('tr_surat')
->join('ms_user', 'tr_surat.user_id=ms_user.user_id', 'left')
->join('ms_subbag', 'ms_user.id_subbag=ms_subbag.id_subbag', 'left')
->join('ms_bag', 'ms_user.id_bag=ms_bag.id_bag OR ms_subbag.id_bag=ms_bag.id_bag', 'left')
->join('ms_div', 'ms_user.id_div=ms_div.id_div OR ms_bag.id_div=ms_div.id_div', 'left')
->join('ms_akses', 'ms_user.id_akses=ms_akses.id_akses', 'left')
->join('tr_revisi', 'tr_surat.no_surat=tr_revisi.no_surat', 'left')
->join('(select r1.id_revisi, r1.tanggal_revisi, r1.no_surat from tr_revisi as r1 join (select max(id_revisi) id_revisi from tr_revisi group by no_surat) as r2 on r1.id_revisi=r2.id_revisi) as revisi', 'tr_surat.no_surat=revisi.no_surat', 'left')
->join('tr_surat as s', 's.no_surat=tr_surat.no_surat', 'left')
->groupBy('tr_surat.no_surat')
->orderBy('tr_surat.no_surat', 'DESC')
->get()->getResultArray();
}

Here's my code for my js script for the table:

$(document).ready(function() {
$('#table-surat-all').DataTable({
ordering:true,
"dom": '<"toolbar">frtip',
"info": false,
"oLanguage": {
"sSearch": "Search"
}
});
} );

I'll really hope you can help me, thank you

Answers

Sign In or Register to comment.