Working with Dynamic Content, Designing a List Widget And Making It React To The User

10501
19
10-26-2023 09:18 AM
JeffreyThompson2
MVP Frequent Contributor
10 19 10.5K

This wound up being a much longer post than I originally intended. It starts off pretty basic for new users, but advanced users should stick around to the end. There will likely be a few things you didn't know you could do.

Let's build a List. (I'm not going to discuss all of the possible options. There are just too many. Nor am I going to try to make something beautiful. This is just an overview of the options available to you.)  I started this project with the Jewelry Box Template so it's already got a List widget with a template. If I want to change the template, I can pick a different one at the top of the Settings panel.

JeffreyThompson2_0-1698264261780.png

I'm going to use this last option. Why? I feel like it, that's why.

JeffreyThompson2_1-1698264411471.png

There's a big button that says I need to select some data, so I press it. I'm making a map of parks so I find my parks feature layer in my map.

JeffreyThompson2_2-1698264631381.png

I'm going to change a few options in the settings panel. I'm going to add a No Data Message. This will show up if I build some filters that filter out all of my parks. It'll say "No parks found". Then I'll click Arrangement and edit some choices in the sub-panel that drops down. Right now there are three pictures per row, I only want two, so I'll change the width to 50%. At the bottom, there are two switches for Scroll Bar and Navigator. Scroll Bar allows the user to scroll through the list and Navigator has little arrows to make the list go up and down. I'll turn them both on. See below to see where I clicked.

JeffreyThompson2_0-1698266144673.png

And my list looks like this...

JeffreyThompson2_1-1698266211114.png

Let's put some stuff in this list. Double click to edit text? Ok, I'll do that. I want this to be the name of the park so I'll use Dynamic Content with the stacked circles icon.

JeffreyThompson2_2-1698266431331.png

I select my park name field (Name1) out of my feature layer and as I close this window my park names appear. When you see the {curly brackets} in Experience Builder, whatever is inside those brackets will be replaced with the value from the field inside those brackets.

JeffreyThompson2_3-1698266709714.png

Now let's fix these pictures. My feature layer has an attribute called PhotoLocation. It's the ending of a URL to where these pictures are located. I can use it to make a unique picture for each park. I click the image, Dynamic, URL and Expression.

JeffreyThompson2_0-1698267326734.png

The park images are stored on my website at https://webapps.arlingtontx.gov/websitephotos/ParkFinder/ + parkName.jpg, but the feature layer only holds the parkName.jpg part. No problem, that's what the Expression is for. In the rectangle near the top of the Expression panel I type (I can't paste in this box.) the following [inside the square brackets, don't use the square brackets]: ["https://webapps.arlingtontx.gov/websitePhotos/ParkFinder/" + ] . Double-quotes and the + sign are important here. Then, I pick PhotoLocation from the list below and hit Insert.

JeffreyThompson2_0-1698328947587.png

Now my List looks like this:

JeffreyThompson2_2-1698329432755.png

Now I'll go back to the List Widget and click the Tools menu open. I'll turn all the options on. Search, Sort and Filter need some configuring, so I'll do that next. Search needs to know what field(s) to search in, so I select Name1 from the dropdown menu. I'll make the Hint text a bit more specific to help out my users and type "Search By Park Name". These parks should be in alphabetical order, so I pick Name1 in the sort option dropdown and click the pencil to rename this sort "Alphabetical". Users may want to find the biggest park, so I hit Add An Option and pick SHAPE.STArea() from the dropdown. This is a standard field that should be in every feature layer. I hit Descending so the biggest parks rise to the top and rename this sort "Largest To Smallest". My Tools menu currently looks like this.

JeffreyThompson2_3-1698330853562.png

Next, I hit Set Filters and the SQL Expression Builder pops up. One day, I may do a post about SQL tricks, but that day is not today. This post is already getting very long and I haven't even gotten to the part I want to talk about yet. As a father of a young child, I need to know if the park has a playground, so I click Add Clause then use the first dropdown to pick PG and in the second dropdown I pick "is not blank".

JeffreyThompson2_0-1698331951191.png

Note: The Set Filter Data Action and the Filter Widget both offer much better user experiences, so maybe use those instead.

Alright this is the part, I have been trying to get to this whole time. Go up a bit in the List Settings panel to States. Here you can change how your list looks based on user interactions. I'm currently using ArcGIS Online, if you are using an older version of Experience Builder, I believe these options are found under Advanced. The Jewelry Box Template already comes with a Selected state enabled. I'm going to click on it to enable editing.

JeffreyThompson2_1-1698332960643.png

At the bottom of the next screen, I switch the layout from Auto to Custom and say Ok to the warning that pops up. Now, I can change how the list appears based on its state. Users have selected this park, so presumably they want to go there. Let's show them the address. In first item in my list, I drag my park name text box to the top of the image and add a new Text widget to the bottom part. The new Text widget is automatically linked to my data. My feature layer does not have a full Address field. I'll need to combine a few fields with an Expression to make a full address. In Dynamic Content, I pick AddressNumber from the menu at the bottom, type + " " + in the box and then pick Street. I click the gear, turn on Number Formatting, turn off the thousands separator and set decimal points to 0. It looks like this.

JeffreyThompson2_3-1698334288611.png

I changed the text color to black so it stands out better against the image and here's what I have.

JeffreyThompson2_4-1698334499581.png

And it works as expected. When the user clicks the park, the address appears.

Let's go a step further. Have you ever seen pictures like this on a website and when you hover your mouse over them but don't click they get a bit bigger? Can we do that in Experience Builder? As I type this, I don't know. Let's find out.

Back in the List settings panel, let's click Hover and then Enable Hover and set the Layout to Custom.

Now I click on the Image for the first park and I drag it to make it bigger. Nope, it doesn't work. But I can make it smaller, so I make it a bit smaller and use the Vertical Centering and Full Height options to put it in the center of the square. To make things a bit silly, I change the image shape to a circle and add a thick border.

Ok, scratch that last paragraph. It sort of works, but it is changing the image in every state. That's not what we want. What if I make this a new image that only shows up in the Hover state? I duplicate my Image widget so I don't have to reconfigure the image link. And send my original image to the Pending list. 

Here's a badly animated gif of my final list.

ezgif.com-gif-maker.gif

19 Comments
MichaelGaiggEsri
Deactivated User

Hey, actually, what you have to do is:

- On the Default state, set dimensions to stretch

MichaelGaiggEsri_0-1699576788836.png

- On the Hover state, do the same but offset the image negative pixels to each side

MichaelGaiggEsri_1-1699576848315.png

 

AlderMaps
Frequent Contributor

This was very helpful for configuring my list; thank you for posting!

Specifically I needed the gory details on how to use images (in my case just solid color pngs blanketing the background of the list item) dynamically via an expression...voila!

Screenshot 2024-07-29 155050.png

Screenshot 2024-07-29 155001.png

JeffreyThompson2
MVP Frequent Contributor

@AlderMaps Using colored boxes as dynamic images is a clever trick for dynamic backgrounds. Could you write it up as a separate post?

Marisa_Kordecki
Regular Contributor

I was hoping I could do something similar but my dynamic expression needs to be based on a date range that gets changed frequently.

JeffreyThompson2
MVP Frequent Contributor

@Marisa_Kordecki Perhaps you could create a calculated field that converts a datetime field into a text value and use that for your dynamic content in Experience Builder.

AndreaB_
Frequent Contributor

Hi! I'm just getting started with Experience Builder and this post was invaluable, thank you!

TatjanaScagliotti1
New Explorer

@AlderMaps How did you do this, this is exactly what I'm trying to accomplish. I want the background or even just the text color to be different based off the value in a field.

JeffreyThompson2
MVP Frequent Contributor

@TatjanaScagliotti1 Take a look at these two posts that discuss similar methods in more detail. A background color that changes based on data is doable in Experience Builder. However, changing the text color would require developing a custom widget.

https://community.esri.com/t5/experience-builder-tips-and-tricks/create-a-map-tips-widget-with-image...

https://community.esri.com/t5/experience-builder-tips-and-tricks/using-a-table-to-update-and-control...

 

doronwen
Frequent Contributor

Hi @AlderMaps 

Do you mind sharing how you did you change the background color of a text field based on the data inside that field? Do I need to use an image as my background? Is that the case?
I have a dynamic text that show percentage between 0-100%. I'd like the text to change color based on the percentage (0%-32% = red, 33%-65% = yellow, 66%-100% = green). But I'll be happy of I can change the background color instead. 

@JeffreyThompson2 I read through the links you shared, but I did not find anything that talks about changing background colors based on dynamic text. 

JeffreyThompson2
MVP Frequent Contributor

I edited the post with a more explicit how-to for this step. It goes something like this.

  1. Create a series of 1x1 pixel colored squares and save them somewhere on the Internet that your site will be able to access. Hosted Images on ArcGIS Online, perhaps?
  2. In your table/data that you will use to control the colors, have a field that contains the full URL to these colored squares.
  3. As the background of your List Widget, use an Image Widget with an Dynamic URL based on the field that points to the colored squares.
Jeaner
by
Occasional Contributor

I apologize if this isn't the best place for this, but is it possible to create a list of specific attributes you want to display but only if those attributes have a value? I want users to be able to select any record (so a filter wouldn't work here) and I have about 10 fields that would potentially contain a value. But if any of those fields does not contain a value, I don't want them to see that field in the list. I have looked and looked and can't figure it out. Any suggestions would be super appreciated. I was able to do this in the popups using Arcade in Classic Web Map but it's not working in the new web map or EB.

 

I moved this question to a better spot. Sorry about that! And thank you for the reply.

JeffreyThompson2
MVP Frequent Contributor

@Jeaner Please take your question over to the official Questions board. It's a bit too off-topic to discuss here.

doronwen
Frequent Contributor

@JeffreyThompson2 what do you mean by "table/data that you will use to control the colors"? Is it a simple spreadsheet that I save in my enterprise folder (with the web map, experience builder app etc.)?


Also, let's assume I do have the table with the URL's figured out, I don't understand how to link that changing image to a dynamic text that is essentially overlayed over that image/background?

BTW, I'm on Enterprise 11.1

JeffreyThompson2
MVP Frequent Contributor

@doronwen In whatever table or other data you are using to make your List, create a field containing URLs. These URLs should reference images of different colors and which URL they direct to should be based on the data. In this post and the other linked posts, there are instructions for using and Image Widget with a URL to have different images for each item in a List.

Ellie_Linden
Occasional Contributor

@JeffreyThompson2 this was an extremely helpful blog! I'm hoping to do something extremely similar, but instead of a feature layer of parks using a table of protected areas. How many protected areas do you think the List widget could handle before Web Experience faces performance issues? This is the only page planned to be within this Web Experience. For the images I currently plan to upload each individually to AGOL then include that URL of the image item to the table (unless you think that would make a difference with performance). Thanks so much!

JeffreyThompson2
MVP Frequent Contributor

@Ellie_Linden If you want a List with images for each item, you will probably see things noticeably slowing down in the hundreds of items. Without images, it should be able to handle tens of thousands of items. 

If you are going to use ArcGIS Online to host imagery, my primary concern would be financial. The cost of imagery storage adds up very quickly. You will be charged at a much lower rate if you store your images as Attachments connected to your Table/Layer.

https://doc.arcgis.com/en/arcgis-online/administer/credits.htm

Ellie_Linden
Occasional Contributor

@JeffreyThompson2 thanks for this! To clarify, when I said "images" I referring to JPEG files of maps exported from ArcGIS Pro (rather than imagery layers). Do you still think the same storage concern applies to that?

JeffreyThompson2
MVP Frequent Contributor

@Ellie_Linden Re-reading that document on Credits, JPEGs and Attachments should be billed at the same relatively low rate of 1.2 Credits per GB per month. You would need to store a lot of pictures to rack up a serious bill at that rate.

Ellie_Linden
Occasional Contributor

@JeffreyThompson2 got it, thanks very much for your help with this!

Contributors
About the Author
A frequently confused rock-hound that writes ugly, but usually functional code.