Mike Otharan
Mike Otharan

Reputation: 953

How do I order my responsive dataTable Jquery?

I always want to show the last result in my table, but now it is responsive and shows me only the first result, how could I order it?

This is my code jQuery

$(document).ready(function() {
        var table = $('#na_datatable').DataTable( {
            rowReorder: {
                selector: 'td:nth-child(2)'
            },
            responsive: true
        } );
    } );

This is my jQuery before being responsive, but sorting the results and always showing the last as first.

$('#na_datatable').DataTable({
   "order": [[ 0, "desc" ]]
});

Upvotes: 0

Views: 51

Answers (1)

Kevin Martins
Kevin Martins

Reputation: 26

resolva isso pela query com order by


public function getLeads($step)
{
    $this->db->select('L.*, P.name as page_name, C.nickname as customer_name, Co.name as user_name');
    $this->db->from('leads L');
    $this->db->join('pages P', 'P.page_id = L.page_id', 'left');
    $this->db->join('customers C', 'C.customer_id = L.customer_id');
    $this->db->join('contacts Co', 'Co.contact_id = L.contact_id', 'left');
    if ($this->data['contact_role'] == 3) {
        $this->db->where('L.contact_id', $this->data['contact_id']);
    }
    $this->db->where('L.customer_id', $this->data['customer_data']['customer_id']);
    $this->db->where('L.step', $step);
    $this->db->order_by('L.date_last_update', 'DESC');
    $this->db->order_by('L.date', 'DESC');
    $query = $this->db->get();
    return $query->result_array();
}

Upvotes: 1

Related Questions