Skip to content
This repository has been archived by the owner on Apr 17, 2019. It is now read-only.

Sort Descending broken #366

Open
acboyle opened this issue Feb 9, 2016 · 2 comments
Open

Sort Descending broken #366

acboyle opened this issue Feb 9, 2016 · 2 comments

Comments

@acboyle
Copy link

acboyle commented Feb 9, 2016

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
Copy link

mverma16 commented May 6, 2016

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

@mverma16
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants