column-sortable icon indicating copy to clipboard operation
column-sortable copied to clipboard

Sorting multiple tables in one request

Open Kyslik opened this issue 9 years ago • 5 comments

See more http://stackoverflow.com/q/40612147/1564365

something like

@sortablelink('username','user name', ['prefix' => 'abc'])

where ['prefix' => 'abc'] is identifier of "sorting instance"

which may be simplified to

@sortablelink('username','user name', 'abc')

Kyslik avatar Nov 20 '16 10:11 Kyslik

Hmm, I just ran into this: multiple tables being grabbed in one request but sortable() is only applied to the first one:

$customers = $customer->sortable(['ChangeDate' => 'desc'])
                                        ->take(10)
                                        ->get();

$contacts = $contact->sortable(['Name' => 'asc'])
                                  ->take(10)
                                  ->get();

I like the "sorting instance" idea, and they could be chained together in the request so the tables retain their sorting when another one is sorted as well: /dashboard?sort=contact.ChangeDate&order=contact.desc&sort=customer.Name&order=customer.asc

benjivm avatar Feb 03 '17 16:02 benjivm

@gmask yes, think about it you are trying to sort two models but you have only one url bar... You can not sort more than one model per request with this package.

Unless I introduce some kind of trickery with sessions (non persistent) or simply base64 encoded sorting = not good looking for end user.

Upon writing original issue I forgot that 3rd parameter already used for different purposes.

Kyslik avatar Feb 03 '17 20:02 Kyslik

i have the same issue as @gmask in my code, i have pages where i use sorted models but without links

AurelDragut avatar Mar 02 '17 13:03 AurelDragut

Why would you use this package without using it in views? If you don't need links just sort your data manually.

Sortable package can be used only once per request because it relies on whatever data are sent through GET parameters (sort, order).

Kyslik avatar Mar 02 '17 17:03 Kyslik

Yeah, you are absolutely right, i did a dumb thing and i corrected it later after my post here.

AurelDragut avatar Mar 02 '17 18:03 AurelDragut