AnsweredAssumed Answered

Identify Task on multiple layers/Return results to datagrid

Question asked by rcsellman on Dec 8, 2014
Latest reply on Dec 9, 2014 by rcsellman

I am trying to add a tool to my app where the user can perform a selection on multiple layers and have the results from all layers return to one datagrid.  I feel like I am close but I am missing something.  I am using an IdentifyTask to do the selection.  Identifying the features is working fine-at the end of drawing my selection, graphics are drawn and the extent zooms to the selection area.  Getting data into the grid is my problem.  Because I am selecting from multiple layers, I am trying to push the selected feature's layerName and value.  Can anyone see whjat I am missing?  Here is the JS:

selectFeaturesTask = new IdentifyTask("");

                selectFeaturesParams = new IdentifyParameters();
                selectFeaturesParams.tolerance = 3;
                selectFeaturesParams.returnGeometry = true;
                selectFeaturesParams.layerIds = [0, 1, 2, 3, 4, 5, 6, 7, 8];
                selectFeaturesParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_ALL;
                selectFeaturesParams.width = map.width;
                selectFeaturesParams.height = map.height;

                selectToolbar = new esri.toolbars.Draw(map);
                dojo.connect(selectToolbar, "onDrawEnd", onSelectEnd);

                function onSelectEnd(extent) {

                function executeFeatureSelection(geom) {
                    selectFeaturesParams.geometry = geom;
                    selectFeaturesParams.mapExtent = map.extent;
                    selectFeaturesTask.execute(selectFeaturesParams, showSelectionResults)


  function showSelectionResults(results) {
  console.log('Features found: ', results);;

  var dataForGrid = [];
  var polygonSymbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_NONE, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_DASHDOT, new dojo.Color([255, 0, 0]), 2), new dojo.Color([255, 255, 0, 0.25]));
  var markerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_SQUARE, 10, new SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255, 0, 0]), 1), new dojo.Color([0, 255, 0, 0.25]));
  var lineSymbol = new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_DASH, new dojo.Color([255, 0, 0]), 1);, function(result) {

  var graphic = result.feature;

  switch (graphic.geometry.type) {
  case "point":
  case "polyline":
  case "polygon":
  return result.feature.attributes;

  var layer = result.layerName;
  var value = result.value;
  dataForGrid.push([layer, value]);
  return result.feature.attributes;
                        var selectData = {
                            items: dataForGrid
                        var selectStore = new ItemFileReadStore({
                            data: selectData

                        selectGrid.on("rowclick", onRowClickHandler);

  var graExtent = esri.graphicsExtent(;   
  map.setExtent(graExtent, true); 


And the HTML showing the grid:

<div data-dojo-type="dijit/layout/ContentPane" title="Select From Multiple Layers">
                    Select from multiple layers:
                    <button dojoType="dijit.form.Button" onClick="selectToolbar.activate(esri.toolbars.Draw.EXTENT);">Select</button>
  <table data-dojo-type="dojox.grid.DataGrid" jsid="selectGrid" id="selectGrid">
                                <th field="0">Layer</th>
                                <th field="1">Value</th>