Cascadingdropdown: How to change the alphabetical order of options?

ldesousa

New Member
Hi!. I have a list created with cascadingdropdown element. I need options listed in the order as they were stored, but they appear in alphabetical order. How I can fix this? Regards.
 
I think it can be done by using the "where" in "Advanced" (it's a workaround, no guaratee that it will do in all circumstances...)

It's expecting a WHERE clause (without leading WHERE), so use a "fake" condition and add the order
1=1 ORDER BY {thistable}.id (ASC or DESC, replace id with the database column name you want to use for ordering)
 
Thanks Troester. I tried what you suggest (1=1 ORDER BY '{thistable}.id' DESC), but options appear in the order found in mysql table, that is, they do not get ordered by id or any other column of the table. I can get the list ordered by id changing a small sentence in the cascadingdropdown.php file. On line 877 of that file, I changed $orderBy = 'text' for $orderBy = 'id'. But I do not like this solution because I'm changing the plugin core. Regards
 
I tried both ways (with or without quotes) but the result is the same. I think your proposal cancels the order established in the line 877 of the file cascadingdropdown.php ($orderBy = 'text') but does not establish a new order
 
Last edited:
Nope. Strangely my mysql table isn't sorted by id. I must comment that the list is huge and I imported a CSV file to load data. I had to do it twice because the first time the file was flawed. When I imported the file a second time, the table wasn't loaded ordered by id. That I did not understand (I think it's a problem for another discussion topic in this forum). The truth is that my mysql table is not ordered by id
 
Last edited:
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top