Select to view content in your preferred language

Use Button to filter list

9889
16
Jump to solution
11-19-2023 02:45 PM
ChrisRoberts2
Frequent Contributor

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

1 Solution

Accepted Solutions
NBC
by
Regular Contributor

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

16 Replies
NBC
by
Regular Contributor

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

 

Boyang_Wang
Frequent Contributor

Can you explain a little further on "create a separate layer containing a single record for each stakeholder type"? Do you meaning creating one layer for only Weekday features and another layer for only Weekend features?

0 Kudos
mpboyle
Honored Contributor

Came across this post when looking for a similar workflow.

I wanted to mention now that ExB supports creating feature sets from Arcade, you can create a feature set on the fly using Arcade to return distinct "categories" based on field values from your target feature layer.  The resulting Arcade feature set can then be used as the selecting list using the same workflow as above.

Below is a sample Arcade script I used to generate a feature set that was then used as a selecting list:

// set portal
var p = Portal('...{url}...');

// set item id 
var item_id = '...{item id}...'

// set layer index
var layer_index = 0

// set desired field
var field = '...{field name}...'

// set where clause
var where = field + ' IS NOT NULL'

// set order by clause
var order_by = field + ' ASC'

// set base feature set
var fs_1 = FeatureSetByPortalItem(p, item_id, layer_index, [field], false);

// set distinct feature set
var fs_2 = OrderBy(Distinct(Filter(fs_1, where), field), order_by)

// return distinct feature set
return fs_2

 

ChrisRoberts2
Frequent Contributor

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!

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