Datatable icon indicating copy to clipboard operation
Datatable copied to clipboard

Sort Descending broken

Open AdamRV9 opened this issue 9 years ago • 2 comments

I'm using Laravel 5 for the first time and am using this plugin to pull data from a MySQL database.

The following code sits inside my controller:

return Datatable::collection(Invoice::all(array('id','date_issued','date_due','user_id','total','status')))
        ->showColumns('id', 'date_issued', 'date_due', 'user_id', 'total', 'status')
        ->searchColumns('id', 'date_issued')
        ->orderColumns('id','date_issued')
        ->make();

This code sits in my blade template:

{!! Datatable::table()
        ->addColumn('Invoice ID','Date Issued','Date Due','Client','Total','Status')
        ->setUrl(route('api.invoices'))
        ->render() !!}

The datatable displays correctly initially, but if I click the "id" or "date_issued" table heading to sort "desc" I get no records, just the message: "No matching records found". If I click the heading again to sort "asc" the records come back.

I can see the AJAX requests via Firebug. The only difference to my eye is sorting "asc" returns an array and "desc" returns on object. I'm not sure if I'm going wrong or if this is a bug...

AdamRV9 avatar Feb 09 '16 22:02 AdamRV9

I am facing the same problem while using datatable with Laravel 5.2

mverma16 avatar May 06 '16 10:05 mverma16

@acboyle I am not sure it is correct or not, but it worked for me. check this [Chumper/Datatable] Fixed for L5.2 compatibility (#372)

mverma16 avatar May 30 '16 08:05 mverma16