For the life of me, I cannot figure this out. I have a function in my Javascript code (below snippet) that does select features returned from search, and will even zoom to single (selected) record rows in the datagrid, but I'd like to have it zoom to all selected features first (from the search). The current functionality is derived from the example here. Sorry I cannot include all of the code, due to reasons for restrictions, but think the included code should contain all needed for the appropriate function. I imagine it should be a simple addition to the code, but I have been researching how to do it, am not a programmer, and could use some help please.dojo.connect(grid, "onRowClick", onRowClickHandler);
function doFind() {
//Set the search text to the value in the box
findParams.searchText = dojo.byId("BUILDING").value;
esri.show(datagrid); //shows the entire datagrid ContentPane upon selecting the "Search" button
dojo.style(dojo.byId("map"), "height", "78%"); //resizes the map (center) pane to manually fit
findTask.execute(findParams,showResults);
}
function showResults(results) {
//This function works with an array of FindResult that the task returns
map.graphics.clear();
var symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([98,194,204]), 2), new dojo.Color([98,194,204,0.5]));
//create array of attributes
var items = dojo.map(results,function(result){
var graphic = result.feature;
graphic.setSymbol(symbol);
map.graphics.add(graphic);
return result.feature.attributes;
});
//Create data object to be used in store
var data = {
identifier: "BUILDING", //This field needs to have unique values
label: "BUILDING", //Name field for display. Not pertinent to a grid but may be used elsewhere.
items: items
};
//Create data store and bind to grid.
store = new dojo.data.ItemFileReadStore({ data:data });
var grid = dijit.byId('grid');
grid.setStore(store);
//Zoom back to the initial map extent
map.setExtent(initExtent);
}
//Zoom to the parcel when the user clicks a row
function onRowClickHandler(evt){
var clickedBuilding = grid.getItem(evt.rowIndex).BUILDING;
var selectedBuilding;
esri.hide(datagrid); //Re-hides the entire datagrid ContentPane after selecting a row in the datagrid
dojo.style(dojo.byId("map"), "height", "98%");
dojo.forEach(map.graphics.graphics,function(graphic){
if((graphic.attributes) && graphic.attributes.BUILDING === clickedBuilding){
selectedBuilding = graphic;
return;
}
});
var BuildingExtent = selectedBuilding.geometry.getExtent();
map.setExtent(BuildingExtent);
}