Laravel-datatables: sorting does not working when using server side laravel-datatables

Created on 29 May 2016  ·  3Comments  ·  Source: yajra/laravel-datatables

when i use data-tables sorting columns woks well
but when using server side laravel-datatables it does not work when clicking on the column header nothing changed no sorting at all !!
although searching works well

this is server code

$provinces = DB::table('provinces')->join('countries','provinces.country_id','=','countries.id')
            ->select(['provinces.id AS proid', 'countries.name AS cname', 'provinces.code AS code', 'provinces.name AS pname'])->orderBy('provinces.name');
        return Datatables::of($provinces)->make(true);

and this is js

$('#provincedataTable').DataTable({
        processing: true,
        serverSide: true,
        stateSave: true,
        ajax: 'province/provinces-json',
        columnDefs: []
    });

"yajra/laravel-datatables-oracle": "v6.11.3"
DataTables 1.10.12
PHP 5.6.15
windows 8.1

Most helpful comment

->orderBy('provinces.name'); seems to be what is stopping this. Try implementing

http://datatables.yajrabox.com/eloquent/order-column

Reference https://github.com/yajra/laravel-datatables/issues/115

All 3 comments

You are using join statement which will affect how the sorting works. See this demo and check how it works.

->orderBy('provinces.name'); seems to be what is stopping this. Try implementing

http://datatables.yajrabox.com/eloquent/order-column

Reference https://github.com/yajra/laravel-datatables/issues/115

thanks ..

Was this page helpful?
0 / 5 - 0 ratings

Related issues

josiahke picture josiahke  ·  3Comments

kamrava picture kamrava  ·  3Comments

sangnguyenplus picture sangnguyenplus  ·  3Comments

ghost picture ghost  ·  3Comments

jackrsantana picture jackrsantana  ·  3Comments