AnsweredAssumed Answered

Zoom to records latitude and longitude in enhanced datagrid

Question asked by flfmmqp on Oct 10, 2014
Latest reply on Oct 14, 2014 by kenbuja

I've looked at all of the examples and I've tried two different ways to zoom to a record in a data grid but I am failing.



*Choice one is to do it as a zoom button in the table but I can not seem to get find the row index!  See bolded lines below.  .


<table  data-dojo-type="dojox.grid.EnhancedGrid" style="height:50px;" jsid="gridStores" id="gridStores" selectionMode="single" data-dojo-props="plugins:{exporter:true, printer:true}">


          <th field="FID" formatter="makeZoomButton" width="30px">

         <img alt="+" src="assets/images/GenericSearch32.png" height="20" width="20"/>


           <th field="WebLon_X" width="100px">WebLon_X</th>

          <th field="WebLat_Y" width="150px">WebLat_Y</th>





     function makeZoomButton(id){
        var zBtn = "<div data-dojo-type='dijit.form.Button'><img src='assets/images/GenericSearch32.png'";
        zBtn = zBtn + " width='18' height='18'";
        zBtn = zBtn + " onClick=\"zoomRow('"+id+"')\"></div>";
        return zBtn;


      function zoomRow(evt){

  // var lon= gridStores.getItem(evt.rowIndex).WebLon_X;

  // var lat= gridStores.getItem(evt.rowIndex).WebLat_Y;


var lon =, "WebLon_X");  

var lat=, "WebLat_Y");  


//--This works if I know row number/index !!!!!

//var lon =, "WebLon_X");  

//var lat=, "WebLat_Y");  

   alert("Current Row Index = " + currentRowIndex);

   var lon =, "WebLon_X");

map.centerAndZoom(new esri.geometry.Point( lon, lat, map.spatialReference),12);




*Choice two was to try and to this on a double click but not sure how well that will work with tablet devices.  I can get cell value but when I use it my zoom does not work ;-(  I am guess formatting because if I hard code it everything seems to work fine.


function onRowDblClickHandler(evt){
if (confirm('Do you wish to zoom to this record?')) {

var items = gridStores.selection.getSelected();
if (items.length) {
    dojo.forEach(items, function(selectedItem) {
        lon =, "WebLon_X");
        lat =, "WebLat_Y");
        //var lon = -12838746.49378;
        //var lat = 4321278.26719; 
  alert("lon = " + lon + "   lat = " + lat);
  map.centerAndZoom(new esri.geometry.Point("" +lon+ "", "" + lat + "", map.spatialReference),12);

// --- end