Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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.