Select to view content in your preferred language

Filter a FeatureTable to only show specific features

2295
3
Jump to solution
06-16-2021 10:29 PM
ewagstaff
Occasional Contributor

Hi all, this issue concerns ArcGIS JS API 4.19.  I've been reading over the FeatureTable documentation and was surprised to see there doesn't seem to be a way to only show a subset of features on the table by providing a list of OBJECTIDs. It shows the entire list of features on a layer, which is much more information than users will need.

There is a way to filter by geometry, only showing features that are in the view extent, which makes me wonder if there is some undocumented method or another strategy altogether that might accomplish this task. But so far I'm at a dead end. I'd like to use ArcGIS' table but if there's no way to show a targeted subset, I might need to roll my own. Please let me know if there's a better way.

0 Kudos
1 Solution

Accepted Solutions
TommyBramble
Regular Contributor

You may be able to apply a definitionExpression to the featureLayer that is associated with the table for the desired results.

If you don't want to modify the featureLayer that is displayed on the map then try creating an in-memory only featureLayer with the desired definitionExpression to link to the featureTable.

View solution in original post

0 Kudos
3 Replies
TommyBramble
Regular Contributor

You may be able to apply a definitionExpression to the featureLayer that is associated with the table for the desired results.

If you don't want to modify the featureLayer that is displayed on the map then try creating an in-memory only featureLayer with the desired definitionExpression to link to the featureTable.

0 Kudos
ewagstaff
Occasional Contributor

Ah I was wondering if something like that would be possible. I'll try it out and see if that works. Thanks for the suggestion!

0 Kudos
ewagstaff
Occasional Contributor

This worked! I was able to do: 
const testlayer = new FeatureLayer({
  url: "https://my-feature-url",
  definitionExpression: "OBJECTID = 87"
});

Thanks!