Ask Your Question
4

How can a row be concealed in ArcGIS Javascript API 4.x using PopupTemplate dependent on an attribute's value?

asked 2023-06-02 08:24:45 +0000

lalupa gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2023-06-02 08:25:02 +0000

pufferfish gravatar image

To conceal a row in ArcGIS JavaScript API 4.x using PopupTemplate, you need to set up a script that will check if the attribute value is equal to a certain value, and then hide the row accordingly.

Here's an example code:

// Set up a PopupTemplate for your layer
var template = new PopupTemplate({
  title: "{Name}",
  content: [{
    // Add a field for the attribute you want to check
    type: "fields",
    fieldInfos: [{
      fieldName: "Attribute_Name",
      visible: true,
      // Use the "visibleWhen" property to set up your condition
      visibleWhen: "{Attribute_Name} != 'Value_to_hide'"
    }]
  }]
});

// Create the layer and apply the PopupTemplate
var layer = new FeatureLayer({
  url: "Layer_URL",
  popupTemplate: template
});

// Add the layer to your Map
map.add(layer);

In the above code, the PopupTemplate will only display the attribute row if the value of "AttributeName" is not equal to "Valueto_hide". If it is, the row will be hidden. You can adjust the condition to fit your needs.

Note that this approach only hides the row in the PopupTemplate, not the actual data itself. If you want to hide the data, you'll need to apply a filter to your layer.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-06-02 08:24:45 +0000

Seen: 7 times

Last updated: Jun 02 '23