I have a Dojo grid that zooms to a selected point on the map when an ObjectId cell in the grid is clicked on. I would like to change this to allow the zoom when the entire row or another attribute such as "Name" is clicked on. The problem is that the ObjectId is my only unique identifier and I am getting no results when modifying and clicking on another field. I have attached a text file that shows the code that I used to generate the grid and also the function that does the querying. Could someone please provide some guidance on what I am missing? Any help is greatly appreciated. Thanks in advance.
Solved! Go to Solution.
You're using the line
grid.on(".field-OBJECTID:click", selectSite);
in your application.
In my application, I'm using the following code to highlight a graphic when the user clicks on a row.
diveGrid.on(".dgrid-row:click", function (evt) { var selectedGrid = registry.byId("diveGrid"); var row = selectedGrid.row(evt); var graphic = returnGraphicFromLayer(row.data.OBJECTID, myGraphicsLayer); if (graphic !== null) { flashFeature(graphic); } }); function returnGraphicFromLayer(featureID, layerGraphic) { for (var i = 0; i < layerGraphic.graphics.length; i++) { if (layerGraphic.graphics.attributes.OBJECTID === featureID) { return layerGraphic.graphics; } } return null; }
You're using the line
grid.on(".field-OBJECTID:click", selectSite);
in your application.
In my application, I'm using the following code to highlight a graphic when the user clicks on a row.
diveGrid.on(".dgrid-row:click", function (evt) { var selectedGrid = registry.byId("diveGrid"); var row = selectedGrid.row(evt); var graphic = returnGraphicFromLayer(row.data.OBJECTID, myGraphicsLayer); if (graphic !== null) { flashFeature(graphic); } }); function returnGraphicFromLayer(featureID, layerGraphic) { for (var i = 0; i < layerGraphic.graphics.length; i++) { if (layerGraphic.graphics.attributes.OBJECTID === featureID) { return layerGraphic.graphics; } } return null; }
Thanks, works great. Out of curiosity, what does your myGraphicsLayer variable refer to? Is it a subset of your layerGraphic feature layer?
That's the graphics layer itself.
var myGraphicsLayer= new GraphicsLayer({ id: "featureGraphics", opacity: 0.5 });