Laravel-datatables: Ordering in client-side

Created on 17 Sep 2018  路  4Comments  路  Source: yajra/laravel-datatables

Summary of problem or feature request

I have a datatables that I sort in query time to get the lastest 200. When I try to sort the datatable in my browser it doesn't work at all, returning me the exact same view. As I had research the sort thing is done in server side.
Why is it server side and how can I change this behaviour?

Code snippet of problem

$collectedTransitions = CollectedTransitions::query()
->orderBy('EVENT_TIME', 'desc')
->limit(self::$maxResults);

  • Operating System
    Ubuntu 18.04.1 LTS

  • PHP Version
    PHP 7.1.4-1+deb.sury.org~xenial+1

  • Laravel Version
    5.4.36

  • Laravel-Datatables Version
    v8.8.0

question

All 4 comments

Hello,

you can disable server side

for example, for service implementation :

public function getBuilderParameters()
{
        return [
           'serverSide'        => false,
        ];
}

if you are not using service implementation, you could disable it in your js for example

$(tables).DataTable({
            serverSide: false
            ajax: [...]
});

and if you are using the html builder alone, you could pass an array of parameters i think:

$datatable->parameters([
     'serverSide'        => false,
     [...]
]);

It does kinda work. When sorting client side not all sort arrows work, some of then still don't changes when I click on then. But now it does work for some of then.

EDIT: In reallity it does ordenate always, but always in ascendent order.
EDIT 2: Is it possible to ordenate by an edited column when in client side?

In reallity it does ordenate always, but always in ascendent order.

It because you already force the ordering: ->orderBy('EVENT_TIME', 'desc')

Is it possible to ordenate by an edited column when in client side?

Yes, possible if you do it via client-side since dataTable will rely on the loaded data and not a server-side request.

It because you already force the ordering: ->orderBy('EVENT_TIME', 'desc')

I'm having trouble with it using clientSide sort, even then is this related?

Yes, possible if you do it via client-side since dataTable will rely on the loaded data and not a server-side request.

When I'm trying to ordenate it client side it works as the field was not edited (E.G when I change the name of something that starts with an A to make it starts with an Z, it gets ordenated as it is an A anyway.)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

FilipeBorges1993 picture FilipeBorges1993  路  3Comments

kamrava picture kamrava  路  3Comments

jackrsantana picture jackrsantana  路  3Comments

t0n1zz picture t0n1zz  路  3Comments

Abdulhmid picture Abdulhmid  路  3Comments