Laravel-datatables: Order, sort, pagination not working after deployment

Created on 30 Jul 2016  路  7Comments  路  Source: yajra/laravel-datatables

On my local (Homestead) environment, datatables works perfectly.

However, after deployment I have noticed that ordering, sorting and pagination does not work. All rows are displayed at once.

This is strange as the code is identical! As far as I can tell.

I have notice that the "draw" doesn't update on the Live version, whereas it does on the Local version, e.g.:

Working: https://www.dropbox.com/s/bgynunxoewpa8d3/Screenshot%202016-07-30%2013.25.20.png?dl=0
Non working: https://www.dropbox.com/s/1e0dh1u2onr7v6c/Screenshot%202016-07-30%2013.25.28.png?dl=0

And the limit on the query is not applied.

Code snippet of JS:

$(function() {
    $('#jobs-table').DataTable({
        processing: true,
        serverSide: true,
        ajax: '{!! route('jobs_datatable') !!}',
        columns: [
            {data: 'ref', name: 'jobs.ref'},
            {data: 'status', name: 'jobs.status'},
            {data: 'name', name: 'jobs.name'},
            {data: 'customer.company_name', name: 'customer.company_name'},
            {data: 'order_date', name: 'jobs.order_date', searchable: false},
            {data: 'action', name: 'action', orderable: false, searchable: false, className: "text-right"}
        ],
        order: [[ 4, "desc" ]]
    });
});

System details

  • Operating System: MacOSX 10.11
  • PHP Version 7.0
  • Laravel Version 5.2
  • Laravel-Datatables Version 6.0

Most helpful comment

Adding

try_files $uri /index.php?$query_string;

to my nginx.conf solved this

All 7 comments

Example of incorrect pagination ("showing 1-10 of 17" but actually showing all 17)

screenshot 2016-07-31 16 48 38

@tomhoad, based on your not working screenshot, it appears that the input parameters are not being sent/received by the server input: []. Not sure how it happens but that should give you some direction to debug.

Thanks @yajra - I bet my nginx.conf is stripping the query strings for whatever reason on the Live server! I'll report back once I amend.

Adding

try_files $uri /index.php?$query_string;

to my nginx.conf solved this

where should i put try_files $uri /index.php?$query_string; ?

@yajra Thanks

@tomhoad tomhoad Thanks, that work for me to

Was this page helpful?
0 / 5 - 0 ratings

Related issues

baig772 picture baig772  路  14Comments

mantrax314 picture mantrax314  路  15Comments

phainv picture phainv  路  16Comments

marioene picture marioene  路  22Comments

jayenn007 picture jayenn007  路  21Comments