Datatable icon indicating copy to clipboard operation
Datatable copied to clipboard

[CollectionProvider]: Need Help

Open mverma16 opened this issue 9 years ago • 4 comments

I used chumper/datatable in my project but after upgrading my Laravel version to 5.2 I started facing issues in sorting in collection. So now I am trying to use Openskill Datatable in laravel 5.2. I tried to implement basic datatable by following the exact steps described in documentation. I am getting an error saying that Class CollectionProvider not found. capture

My controller function looks like 1

And in my view 2

I am not sure, am I doing something wrong? Please help me out.

mverma16 avatar May 19 '16 09:05 mverma16

You do not have the correct use statements, to import the classes into your namespace.

Add this:

use OpenSkill\Datatable\DatatableService;
use OpenSkill\Datatable\Providers\CollectionProvider;

timgws avatar May 19 '16 12:05 timgws

@timgws Thank you, I knew I was doing something stupid as hell.

mverma16 avatar May 19 '16 13:05 mverma16

Hey Looks like some thing is still wrong in my project code. I am getting an ajax error. by looking request on my localhost -

http://localhost/?draw=1&columns%5B0%5D%5Bdata%5D=name&columns%5B0%5D%5Bname%5D=&columns%5B0%5D%5Bsearchable%5D=true&columns.....' and gives the response as 1

I guess request is being send to wrong URL it should be like

http://localhost/myproject[/public]?draw=1&columns%5B0%5D%5Bdata%5D=name&columns%5B0%5D%5Bname%5D=&columns%5B0%5D%5Bsearchable%5D=true&columns.....'

Please tell me, what am I doing wrong? @Chumper I started facing issues in Chumper/Datatable after upgrading Laravel version of my project to 5.2. Sorting creates a problem and returns response which is not being rendered in datatable. Is this an issue with datatable itself? Can you help me to solve it because I'd like to stick to chumper datatable till the complete documentation for openskill is not available.

mverma16 avatar May 24 '16 07:05 mverma16

@mverma16 it looks like you are not setting the endpoint for the route that will handle the datatable request. (https://github.com/OpenSkill/Datatable/pull/20)

Build your datatable like this:

{{
    $datatable
        ->headers() // tell the table to render the header in the table
        ->columns('id', '#') // show # in the header instead of 'id'
        ->columns('name', 'Full name') // show 'Full name' in the header instead of 'name'
        ->endpoint(route('asd.asd'))
        // render just the table
        ->table()
}}

You should replace route('asd.asd') with either the name of the route, or with the URL that will handle the request.

timgws avatar May 25 '16 03:05 timgws