I try to select some parcels and shows the results on the same previous search results datagrid table. I only able to see additional graphics being add on the map but no additional parcels being added to the current table. Besides that, how do you shows the total results after you added the selection parcels?
Here is my jsfiddle:
Please help me to take a looks. Thank you.
Solved! Go to Solution.
I made a couple of changes to it here to make it work correctly. Your issue was that you were populating the array "parcelItems" with only the new features selected. You want to add these features to that array instead. This is the new version of the function.
function onDrawEnd2(extent) { //clearParcelGrid(); toolBar2.deactivate(); var query2 = new esri.tasks.Query(); query2.geometry = extent; featureLayerParcel.selectFeatures(query2, esri.layers.FeatureLayer.SELECTION_ADD, function (features, selectionMethod) { var newparcelItems = dojo.map(features, function (feature) { return feature.attributes; }); arrayUtils.forEach(newparcelItems, function (item) { parcelItems.push(item); }); parcelData = { identifier: "PARCELID", items: parcelItems }; parcelStore = new dojo.data.ItemFileWriteStore({ data: parcelData }); parcelGrid = registry.byId("gridP"); parcelGrid.setStore(parcelStore); document.getElementById("totalresults").innerHTML = parcelItems.length + " result(s)."; arrayUtils.forEach(features, function (feature) { graphic = new Graphic(feature.geometry, symbol); map.graphics.add(graphic); }); }); }
I initialized this variable as an array at the beginning of the script and also emptied the array in the clearParcelGrid function to prepare it for searches.
I made a couple of changes to it here to make it work correctly. Your issue was that you were populating the array "parcelItems" with only the new features selected. You want to add these features to that array instead. This is the new version of the function.
function onDrawEnd2(extent) { //clearParcelGrid(); toolBar2.deactivate(); var query2 = new esri.tasks.Query(); query2.geometry = extent; featureLayerParcel.selectFeatures(query2, esri.layers.FeatureLayer.SELECTION_ADD, function (features, selectionMethod) { var newparcelItems = dojo.map(features, function (feature) { return feature.attributes; }); arrayUtils.forEach(newparcelItems, function (item) { parcelItems.push(item); }); parcelData = { identifier: "PARCELID", items: parcelItems }; parcelStore = new dojo.data.ItemFileWriteStore({ data: parcelData }); parcelGrid = registry.byId("gridP"); parcelGrid.setStore(parcelStore); document.getElementById("totalresults").innerHTML = parcelItems.length + " result(s)."; arrayUtils.forEach(features, function (feature) { graphic = new Graphic(feature.geometry, symbol); map.graphics.add(graphic); }); }); }
I initialized this variable as an array at the beginning of the script and also emptied the array in the clearParcelGrid function to prepare it for searches.