Query Builder Widget

71
1
yesterday
Labels (2)
PartyPelican
Occasional Contributor

Hello, I have been trying to make a query builder 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.

Query Builder.gif

0 Kudos
1 Reply
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.