Select to view content in your preferred language

Is there a way to sort the Filter widget dropdown menu items

792
4
06-13-2024 05:45 AM
FranklinAlexander
Frequent Contributor

I need to display the items in the Filter widget dropdown menu in a specific order, but cannot find a way to do it. Esri seems to automatically sort the items in alphabetical order, which is great in most cases, but not in this case. The items needs to be sorted in the same order as they appear in the Legend and it's very important. I tried using the 'Predefine unique values' option in the Expression Builder to order the items the way I need them in the hopes that this order would be honored in the selection menu, but they are being re-ordered some place in the code.

 

PredefinedOptions.PNGValueOptions.PNG 

 

 

 

 

 

I logged the value options from the .tsx file and they are in the correct order here.

 

 

Here is the order that they appear in the dropdown menu:

MenuSortIssue.PNG

 

 

 

 

 

 

 

Does anyone know if I am missing something obvious, or where in the code the html for the dropdown menu is being created? 

0 Kudos
4 Replies
NicoleJohnson
Frequent Contributor

Seems that this has been an issue for a while. Here's an idea you can upvote: Filter Widget | Option to display order of predefi... - Esri Community

For a workaround, maybe consider adding the values as separate filters (one filter widget, different filters for each value, all set up with "or," not "and"), since you're already only allowing users to choose one of the values? Something like the attached picture. If space is at a premium in your app, maybe have a "Filter By Abundance" button that links to an anchored window that opens up just under the button, then put all your filters in there.

 

0 Kudos
FranklinAlexander
Frequent Contributor

Thanks for the suggestions Nicole. I often use the separate filters in the way you suggested, but in the case our stakeholders want to keep things as simple and clean as possible. I like the anchored window idea as well, if closing it wasn't an issue. The popup menu closes when a selection is made, but I'm not sure that would be configurable with the window. It's always something! 🙂

emarcelloni
Occasional Contributor

Hello@FranklinAlexander how are you?

I tried but I couldn't replicate your problem. In my case I use ExperienceBuilder from an ArcGis Enterprise 10.9.1 and the filter dropdown follows the same order as I defined in the configuration menu.

Wich Version are you using?

Regards! Esteban Marcelloni

Image 1: Alphabetic Order

Orden Alfabetico.png

Image 2: Ramdom Order

Orden Ramdon.png

 

0 Kudos
FranklinAlexander
Frequent Contributor

That's weird, I am using Developer version 1.14. Usually the Enterprise version is the last to get the updates, so you would think my version would have the same behavior. Could be a bug I guess.

0 Kudos