31

I'm hoping to find some existing code which emulates the "Select by Attributes" dialog in ArcMap, within the ArcGIS Server JavaScript API.

Writing a hard-coded QueryTask is easy - I'm looking for some code which will automatically handle any layer on the map, forming a Query on-the-fly using any attributes, ideally returning the results into a datagrid.

Clever people have written Table of Contents and Identify widgets which handle any layers in the map. Has anyone written something similar for "select by attributes"?

mgri
  • 16,159
  • 6
  • 47
  • 80
Stephen Lead
  • 21,119
  • 17
  • 113
  • 240
  • Did you ever find a solution to this? –  Dec 07 '11 at 17:17
  • Nothing yet, sorry – Stephen Lead Jun 04 '12 at 14:34
  • Do you try the find task ? http://help.arcgis.com/en/webapi/javascript/arcgis/samples/find_map/index.html –  Nov 07 '12 at 20:27
  • @Julien thanks but that's not really suitable. I've parked this requirement for now, but I'd like to sort it out one day... – Stephen Lead Nov 08 '12 at 00:13
  • @Stephen ..According to my knowledge there is no ready-made code is available ..You idea is very good so you can mention your idea to "ArcGIS Ideas" website..thanks – Sunil Nov 19 '12 at 11:07
  • I'm not too familiar with the AGS JS API but this is pretty easy to do in arcpy. What makes it tricky in the JS API? – blah238 Jan 02 '13 at 07:18
  • 2
    I wasn't aware that there is some specific plugin architecture for the Javascript API. Were you looking for a dojo widget which works and looks like the Select By Attribute window in ArcMap? – Devdatta Tengshe Jan 02 '13 at 10:39
  • 1
    @DevdattaTengshe I was hoping for something similar to this TOC sample which is easy to integrate – Stephen Lead Jan 06 '13 at 23:43
  • @StephenLead may be useful http://forums.arcgis.com/threads/75311-Nested-group-layer-visibility-in-AGSJS-TOC?s=5da7e51e3e167b971daa1cba9438b75e – Sunil Jan 18 '13 at 12:56
  • I may be underthinking this, but would it be possible to define a function that takes the desired parameters and passes them into your query, then resets and waits for additional selections? – Jay Guarneri Feb 22 '13 at 02:44

3 Answers3

4

A couple of years later, I was looking for exactly the same thing as the OP. This question shows up in the top results of a search engine, so I decided to leave this update here as a reference.

In the Summer of 2015, Esri has released a Select by Attributes Widget in their GitHub repository.

This widget attempts to recreate ArcMap's select by attributes tool as accurately as possible within a JavaScript application. This widget only works with feature layers and these must be passed to the widget's constructor as an array.

Live Sample

iled
  • 353
  • 4
  • 11
4

If you are using ArcServer 10.1 you could create a Geoprocessing service which references either a model or script that you built to do this.

The link above gives step by step instructions on how to create the model, then create the services and finally consume it in your app.

Alternatively, there is this sample that uses a query to select records, you could modify that to allow for multiple services.

Craig
  • 4,570
  • 7
  • 40
  • 71
0

It's clear that there is an appetite for a plugin like this.

As everyone has noted, there's nothing particularly difficult about running a single, simple query. Where it gets complicated is building an interface to help the user to write a valid query for the current layer(s) on the map, running the query, then doing something with the result(s).

I ended up writing a bespoke solution which does all of the above, which took a good week or so of development.

My solution is embedded reasonably tightly into the rest of my mapping framework, so unfortunately it's not easy to "export" this into a stand-alone "select by attributes plugin" - possibly why nothing like this exists so far?

Stephen Lead
  • 21,119
  • 17
  • 113
  • 240