Select by Widget

1249
4
04-22-2025 08:54 PM
PartyPelican
Regular Contributor

Hello, I have been trying to make a "select by" widget that looks similar and functions similar to the "Select by" tools we have in ArcGIS Pro. I have something working but I have questions on how to improve it. 

1. The widget uses the dataSource.selectRecords method, but I don't see an option in that method for additional selection methods like "add to selection" or "remove from selection". Does anyone know of an alternative method? Right now, it'll just make a new selection. 

2. When using the select by location option, if no features or multiple features are selected in the Selecting Features, then the widget unions the geometry of all those features. This is because I can only pass in a single geometry in the selectRecords method. However, I am using the unionOperator from the JavaScript SDK and the returned results doesn't seem to work with the selectRecords because of type differences. selectRecords expects IGeometry and I am passing in __esri.GeometryUnion. To get around this, I have an ugly function that returns only the necessary fields based on the type of geometry. Does anyone know of a better way to get around this?

The code is here.

Update:

I was able to solve the 2 issues above. Please let me know if there are ways of improving this. Hope someone finds this useful!

(view in My Videos)

0 Kudos
4 Replies
AndreLoerch
Occasional Contributor

At least for #1 (I don't know about #2), you could return the selected records' OIDs from the layer(s) and store them, then get the OIDs from the subsequent query and add them to the variable where you stored the existing selected records' OIDs, and make a new selection from that. I'm not sure if there's a built-in add to selection parameter either.

Forestkane
Emerging Contributor

Did you find the fix for #2? 

0 Kudos
JasonBOCQUET
Frequent Contributor

Hi, on the setting of the widget it is possible to made action by using selecting records and common ID's ?

0 Kudos
PartyPelican
Regular Contributor

Are you looking to select other layers based on a specified field?

0 Kudos