AnsweredAssumed Answered

Need help with adding additonal search to sample "Show find results in a Data Grid"

Question asked by laura.teisl on May 2, 2014
Latest reply on May 7, 2014 by laura.teisl
I am attempting to add an additional service and, hence, an additional search, to the sample "Show find task results in a Data Grid."  I successfully added the search fields in a drop down box (thanks to your help), but I have lost my results.  Also, the results table for the second service is not displaying.

Any help would be appreciated.    Below is a portion of the code:

          var featureLayer = new FeatureLayer("http://ummgis.umm.maine.edu:6080/arcgis/rest/services/testing/SpecFoodProdGIS428/MapServer/0",{             mode: FeatureLayer.MODE_ONDEMAND,             outFields: ["*"]         });                                          var query = new Query();         query.where = "1=1";          featureLayer.queryFeatures(query, function(featureSet) {                 nameList = [];                      dojo.map(featureSet.features, function(feature) {             nameList.push(feature.attributes.org_name);           });                        arrayUtils.forEach(nameList, function(feature){                                           registry.byId("specialtyName").get('store').add({ name: feature});           })                });           var featureLayer = new FeatureLayer("http://ummgis.umm.maine.edu:6080/arcgis/rest/services/testing/ProcessorsGIS428/MapServer/0",{             mode: FeatureLayer.MODE_ONDEMAND,             outFields: ["*"]         });                                  var queryProcessor = new Query();         queryProcessor.where = "1=1";          featureLayer.queryFeatures(queryProcessor, function(featureSet) {                 nameList = [];                      dojo.map(featureSet.features, function(feature) {             nameList.push(feature.attributes.ORG_NAME);           });                        arrayUtils.forEach(nameList, function(feature){                                           registry.byId("processorName").get('store').add({ name: feature});           })                });            findTask = new FindTask("http://ummgis.umm.maine.edu:6080/arcgis/rest/services/testing/SpecFoodProdGIS428/MapServer");          map.on("load", function() {           findParams = new FindParameters();           findParams.returnGeometry = true;           findParams.layerIds = [0];           findParams.searchFields = ["org_name"];           findParams.outSpatialReference = map.spatialReference;         });          function doFind() {           findParams.searchText = dom.byId("specialtyName").value;           findTask.execute(findParams, showResults);         }          function showResults(results) {                 map.graphics.clear();           var symbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 12,              new SimpleLineSymbol(SimpleLineSymbol.STYLE_NULL, new Color([0, 0, 0, 1]), 1), new Color([255, 0, 0, 1])                     );            var items = arrayUtils.map(results, function(result) {             var graphic = result.feature;             graphic.setSymbol(symbol);             map.graphics.add(graphic);             return result.feature.attributes;           });                      var data = {             identifier : "Specialty", //This field needs to have unique values             label : "Specialty", //Name field for display. Not pertinent to a grid but may be used elsewhere.             items : items           };                      store = new ItemFileReadStore({             data : data           });           var grid = registry.byId("grid");                      console.log(store);                      grid.setStore(store);           grid.on("rowclick", onRowClickHandler);            map.centerAndZoom(center, zoom);         }          function onRowClickHandler(evt) {           var clickedOrgName = evt.grid.getItem(evt.rowIndex).org_name;           var selectedOrgName = arrayUtils.filter(map.graphics.graphics, function(graphic) {             return ((graphic.attributes) && graphic.attributes.org_name === clickedOrgName);           });           if (selectedOrgName.length) {             var center2 = [selectedOrgName[0].geometry.getLongitude(), selectedOrgName[0].geometry.getLatitude()];             var zoom2 = 15;             map.centerAndZoom(center2, zoom2);           }         }          findTask = new FindTask("http://ummgis.umm.maine.edu:6080/arcgis/rest/services/testing/ProcessorsGIS428/MapServer/0");          map.on("load", function() {           findParamsProcessor = new FindParameters();           findParamsProcessor.returnGeometry = true;           findParamsProcessor.layerIds = [0];           findParamsProcessor.searchFields = ["ORG_NAME"];           findParamsProcessor.outSpatialReference = map.spatialReference;         });          function doFind() {           findParamsProcessor.searchText = dom.byId("processorName").value;           findTask.execute(findParamsProcessor, showResults);         }          function showResults(results) {                 map.graphics.clear();           var symbolProcessor = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 12,              new SimpleLineSymbol(SimpleLineSymbol.STYLE_NULL, new Color([0, 0, 0, 1]), 1), new Color([122, 0, 0, 1])                     );            var itemsProcessor = arrayUtils.map(results, function(result) {             var graphicProcessor = result.feature;             graphic.setSymbol(symbolProcessor);             map.graphics.add(graphic);             return result.feature.attributes;           });                      var dataProcessor = {             identifier : "Processor", //This field needs to have unique values             label : "Processor", //Name field for display. Not pertinent to a grid but may be used elsewhere.             items : itemsProcessor           };            store = new ItemFileReadStore({             data : dataProcessor           });           var gridProcessor = registry.byId("gridProcessor");                      console.log(store);                      grid.setStore(store);           grid.on("rowclick", onRowClickHandler);            map.centerAndZoom(center, zoom);         }          function onRowClickHandler(evt) {           var clickedProcessorName = evt.grid.getItem(evt.rowIndex).ORG_NAME;           var selectedProcessorName = arrayUtils.filter(map.graphics.graphics, function(graphic) {             return ((graphic.attributes) && graphic.attributes.ORG_NAME === clickedProcessorName);           });           if (selectedProcessorName.length) {             var center2 = [selectedProcessorName[0].geometry.getLongitude(), selectedProcessorName[0].geometry.getLatitude()];             var zoom2 = 15;             map.centerAndZoom(center2, zoom2);           }         }      });           </script>   </head>   <body class="claro">     <div data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="design:'headline'" style="width:100%;height:100%;margin:0;">       <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'top'" style="height:40px;">         Specialty Food Producer name:         <!--<input type="text" id="specialtyName" size="60" value="Northern Girl" />-->         <select id="specialtyName" data-dojo-type="dijit.form.ComboBox" style="width:200px;font-size:16px;"           value="Select a Company"></select>         <button id="search" data-dojo-type="dijit.form.Button" type="button" data-dojo-attach-point="button" >           Search         </button>         Processor name:         <!--<input type="text" id="processorName" size="60" value="Acorn Kitchen" />-->         <select id="processorName" data-dojo-type="dijit.form.ComboBox" style="width:200px;font-size:16px;"           value="Select a Company"></select>         <button id="search" data-dojo-type="dijit.form.Button" type="button" data-dojo-attach-point="button" >           Search         </button>       </div>       <div id="map" data-dojo-props="region:'center'" data-dojo-type="dijit/layout/ContentPane" style="border:1px solid #000;"></div>       <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'bottom'" style="height:150px;">          <table data-dojo-type="dojox/grid/DataGrid" data-dojo-id="grid" id="grid" data-dojo-props="rowsPerPage:'5', rowSelector:'20px'">           <thead>             <tr>               <th field="Name">Name</th>               <th field="City" >City</th>               <th field="Contact">Contact</th>               <th field="Products">Products</th>               <th field="Products Used" width="100%">Products Used</th>             </tr>           </thead>         </table>                  <table data-dojo-type="dojox/grid/DataGrid" data-dojo-id="gridProcessor" id="gridProcessor" data-dojo-props="rowsPerPage:'5', rowSelector:'20px'">           <thead>             <tr>               <th field="Name">Name</th>               <th field="City" >City</th>               <th field="Contact">Contact</th>               <th field="Type of Processor" width="100%">Type of Processor</th>             </tr>           </thead>         </table>        </div>     </div>   </body> </html>

Outcomes