Use Button to filter list

1564
12
Jump to solution
11-19-2023 02:45 PM
ChrisRoberts2
Occasional Contributor III

Hi All

Is it possible to use the button widget to filter  the values in a List Widget?  For example I would a couple of buttons with the main stakeholder types.  When the user clicks one of the Buttons, say Government,  the corresponding list filters down to only show those that are a Government stakeholder.

Thanks in advance

0 Kudos
1 Solution

Accepted Solutions
NBC
by
New Contributor III

Hi Chris, 

I don't think the button widget can do this yet.  One workaround I would suggest is to create a separate layer containing a single record for each stakeholder type and use this as your data input for a separate list widget.  You'll then be able to filter the main list with this new list by Add a trigger > Record selection changes > Framework > Filter Data Records.  Once you've got the new list set up you can format things to look like buttons.
Below is an example of one I've done recently where its filters weekday/weekends.
https://experience.arcgis.com/experience/aaaa20adb7a740249d338f9a071c46a8

Cheers

Andrew

 

View solution in original post

12 Replies
NBC
by
New Contributor III

Hi Chris, 

I don't think the button widget can do this yet.  One workaround I would suggest is to create a separate layer containing a single record for each stakeholder type and use this as your data input for a separate list widget.  You'll then be able to filter the main list with this new list by Add a trigger > Record selection changes > Framework > Filter Data Records.  Once you've got the new list set up you can format things to look like buttons.
Below is an example of one I've done recently where its filters weekday/weekends.
https://experience.arcgis.com/experience/aaaa20adb7a740249d338f9a071c46a8

Cheers

Andrew

 

ChrisRoberts2
Occasional Contributor III

Nice tip!

Thanks Andrew

0 Kudos
MichaelGaigg
Esri Contributor

Hi @ChrisRoberts2 - this is very easy actually, use the filter, either the built-in filter of the list widget or the filter widget itself. As long as the values you want to filter are part of the layer you display in the list, this works just fine.

There are two things to do when you build your expression:

- set the source  type (values you want to display) to Unique, or if you only want to show some,  the change to Unique (predefined) and set them there (this is also how  you'd  remove the "all" option if that's not what you want to include)

- change the input style from dropdown list to  pill selector

MichaelGaigg_0-1700459525223.png

Good luck!

0 Kudos
MichaelGaigg
Esri Contributor

Actually, if you want to remove the "All" option, you need to change the operator to "is any of", that will leave you with the available options only. Still set the input style to pill selector

MichaelGaigg_1-1700463364992.png

 

0 Kudos
RobertAnderson3
MVP Regular Contributor

Hi @MichaelGaigg 

I love the pill selector option, this is what I'm using in my AGOL based ExB, two issues though.

With Unique (predefined) there is no Choose input style button, so the pill selector look is not an option?

With using is any of to remove the -ALL- it turns the filter into a select multiple, I want to keep it as a single selection filter, but without the -ALL- 

So neither of these solutions really get me where I want to be with my filter.

0 Kudos
MichaelGaigg
Esri Contributor

@RobertAnderson3 yeah, last resort is to use Unique, which gives you exactly what you need (plus the all option), then wrap the filter into a fixed panel

MichaelGaigg_0-1702656169364.png

 

and offset the filter itself by -70px (or whatever hides the all option)

MichaelGaigg_1-1702656249381.png

 

0 Kudos
RobertAnderson3
MVP Regular Contributor

A bit of a goofy option for a workaround but I may have to run with that for the time being. The offset might be a challenge to directly offset considering different device sizes, but I'll give it a shot, thanks!

If you could nudge the team working on such things to either add a setting to get rid of the all, or add the pill selector to Unique (predefined) that would be great too! (I feel like the pill should be simple? But I know I have no idea)

Thank you!

0 Kudos
MichaelGaigg
Esri Contributor

Well, I hate to say this, but you are asking for a radio buttons list. UX best practices for radio buttons require that user must select exactly one choice and this choice is mutually exclusive. As a result, you should select an option by default and users can *not* unselect the options (just toggle to another one). This behavior conflicts with filtering best practices because users won't be able to ever see all the options.

0 Kudos
RobertAnderson3
MVP Regular Contributor

Ah if it's supposed to be something different that's fair, just quickly then, in my case I am looking to show infrastructure projects based on the year started, designed to replace the Shortlist Storymap template.

RobertAnderson3_2-1702671323132.png

I have a layer view created to not include unapproved projects (year set as 0) or in the future I will do the same for older projects once this app has been around longer and they're not as relevant to the public.

I have a default option on the filter (2023) and only want the user to be able to pick by year, no need for an all option, and have it filter the list widget and the map widget. The pills are more user friendly than the drop down I find. The filter was just the cleanest way I found to do this.

RobertAnderson3_0-1702671192633.png

If what I'm looking to do is radio buttons for a list, how is it recommended to implement this in ExB? Is there an existing widget/development strategy, or a planned widget in the future?

Thank you and have a great weekend!

0 Kudos