Chumper / Datatable

This is a laravel 4 package for the server and client side of datatables at http://datatables.net/
https://github.com/Chumper/Datatable
388 stars 154 forks source link

Sort Descending broken #366

Open acboyle opened 8 years ago

acboyle commented 8 years ago

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...

mverma16 commented 8 years ago

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

mverma16 commented 8 years ago

@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)