Sorting 3 different fields.

Talk about Sorting & Paging problems, issues etc.

Moderator: alexandrleonenko

al.mariani@teletu.it
Senior
Senior
Posts: 26
Joined: Nov 26th, '14, 20:57

Sorting 3 different fields.

Postby al.mariani@teletu.it » Apr 27th, '16, 16:26

Hi,
Is It possible sorting 3 different fields, increasing or decreasing order: Date - Hour - Stadium?
1. order to date;
2. order to hour;
3. order to stadium;
Best regards.
Alberto
Attachments
IMG1.jpg
IMG1.jpg (34.94 KiB) Viewed 5538 times

ne_moj
Master
Master
Posts: 243
Joined: Jan 1st, '16, 14:11

Re: Sorting 3 different fields.

Postby ne_moj » Apr 29th, '16, 16:47

Hello Alberto,

I don't quite understand your question. If you want to sort on several fields, it is not possible.

Regards Sergey.

Emmanuel71
Junior
Junior
Posts: 11
Joined: Apr 19th, '13, 17:56

Re: Sorting 3 different fields.

Postby Emmanuel71 » Oct 13th, '16, 09:56

You can't is a bit a bold statement even from a master :-) . I think it really depends on what you want to do. For starters there is the option to set the default sorting order to multiple fields in code. Put this, for instance, after the declaration of your sql-statement:
$default_order = array("field1"=>"desc","field2"=>"desc","field3"=>'asc'); (asc= ascending; desc=descending)

Also if your db is mysql, you could concat the 3 fields in your sql-statement like this:
select concat(field1, field2, field3) as sort_string, ... . Which makes the column clicable at runtime.

Also have a look at the sort_by option of columns. This allows you to sort on another column than the one displayed at runtime, which opens several sorting opportunities.

However, if you want to sort on multiple colums by clicking on them at runtime, I haven't found how to do this yet. I think that is indeed not possible. It would maybe be a nice feature request.

ne_moj
Master
Master
Posts: 243
Joined: Jan 1st, '16, 14:11

Re: Sorting 3 different fields.

Postby ne_moj » Oct 14th, '16, 19:55

Thank you Emmanuel

I really should not be so bold in the statements :) After all, if I did not succeed, it does not mean that there are no other solutions.


Return to “Settings: Sorting & Paging”