Select to view content in your preferred language

Add more selection parcels to current datagrid

2689
1
Jump to solution
04-22-2015 10:23 AM
MayJeff
Deactivated User

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:

Edit fiddle - JSFiddle

Please help me to take a looks.  Thank you.

0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

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.

View solution in original post

0 Kudos
1 Reply
KenBuja
MVP Esteemed Contributor

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.

0 Kudos