Select to view content in your preferred language

OnRowClick Issues in 3.3

1073
5
02-21-2013 11:35 AM
EmilyLaMunyon
Deactivated User
Hi,
I am upgrading my application from 3.2 to 3.3 and in the process noticed that my OnRowClickHandler function no longer works. When I click on a row in my dojo data grid, nothing happens. I can see the selected feature on the map, I just can't zoom to it anymore. I have my connection to the grid, dojo.connect(grid2, "onRowClick", onRowClickHandler); inside my init() function as well. Also, there are no errors showing up in Firebug which is making it hard to pinpoint the problem. Has anyone else come across this issue?
Any insight would be greatly appreciated!
 function onRowClickHandler(evt){ 
  console.log(searchType);
  if (searchType == 'City') {
   var clickedTaxLotId = grid2.getItem(evt.rowIndex).CITY; 
   var selectedTaxLot; 
   var highlightSymbol = new esri.symbol.SimpleMarkerSymbol().setColor(new dojo.Color([255,255,0,0.3])); 
   dojo.forEach(map.graphics.graphics,function(graphic){ 
     if((graphic.attributes) && graphic.attributes.CITY === clickedTaxLotId){ 
    selectedTaxLot = graphic; 
    graphic.setSymbol(highlightSymbol);
       return; 
     } 
        }); 
  
   if ( selectedTaxLot.geometry.declaredClass == 'esri.geometry.Point' ) {
          map.centerAndZoom(taxLotExtent, 14)
   var sp = map.toScreen(selectedTaxLot.geometry);
   map.infoWindow.show(selectedTaxLot.geometry, map.getInfoWindowAnchor(sp));
   } else {
   var taxLotExtent = selectedTaxLot.geometry.getExtent(); 
   var screenpoint = map.toScreen(selectedTaxLot.geometry.getExtent().getCenter());
   var mappoint = map.toMap(screenpoint);
   map.setExtent(taxLotExtent,true);
   }
     }
}
0 Kudos
5 Replies
EmilyLaMunyon
Deactivated User
I am still having this issue after trying multiple things, has anyone else noticed their OnRowClick does not zoom to feature in 3.3?
0 Kudos
GabiVoicu
Deactivated User
I did notice on my app that my zoom to point feature does not work anymore and I beleive it has something to do with changing or setting the extent
....as I was reading in another thread pasted here below
http://forums.arcgis.com/threads/80077-Update-to-ArcGIS-JS-API-3.3
interesting enough that zooming to polygons is fine so only the point features manipulated with a expand factor are problematic
If i were to guess right your grid is returning point features is that correct?

Thank you
0 Kudos
EmilyLaMunyon
Deactivated User
Thanks for the reply Gabi.

Zooming in 3.3 is not working on any of my layers, whether they are points or polylines. In addition, there are no errors in Firebug to even give me a clue as to what is going on.

I will look into the spatial extent issue a little more and let you know if I find anything.

Thanks!!
0 Kudos
DianaBenedict
Frequent Contributor
I had a similar issue when attempting to zoomToFeature when the geometry is a point. I noticed that if the extent was "too small" then it would simply revert back to the exent that I was originally in.

I had to do a complete "rehaul" of my ZoomToFeature method to get this to work correctly. I ended up having to use the buffer task to do this. I created a quick method to handle any case where I either pass in one or more graphics to zoom to.  Below is a simplified version of the code.

function zoomToGraphics(graphicsArray, expandFactor) {
  var zoomExtent = esri.graphicsExtent(graphicsArray);
  //If the extent height and width are 0, null is returned by ESRI method above
  if (!zoomExtent) {
    var geomArray = esri.getGeometries(graphicsArray);
    var deferred = bufferGeometry("http://myserver/arcgis/rest/services/Utilities/Geometry/GeometryServer",
                            geomArray, [0.02], map.spatialReference, map.spatialReference);
    deferred.then(function (results) {
      map.setExtent(results[0].getExtent());
    }, function (error) {
       //place holder for error handling      
       alert("Error during buffer Geom: " + error.message);
    });
  } else {
    if (expandFactor) {
      map.setExtent(zoomExtent.expand(expandFactor));
    } else {
      map.setExtent(zoomExtent);
    }
  }
}

0 Kudos
EmilyLaMunyon
Deactivated User
I finally found a solution to the zoom issue in 3.3. Since clickedTaxLotId is an array, we need to take the first value that will contain
the name.

The if statement was initially:
if((graphic.attributes) && graphic.attributes.CITY === clickedTaxLotId)

In 3.3 it needs to be:
if((graphic.attributes) && graphic.attributes.CITY === clickedTaxLotId[0])

Hope this helps someone!
0 Kudos