function doFind() { //Set the search text to the value in the box findParams.searchText = dojo.byId("parcel").value; //grid.showMessage("Loading..."); //Shows the Loading Message until search results are returned. 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: "Parcel Identification Number", //This field needs to have unique values. USES THE ALIAS!!! label: "PARCELID", //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(startExtent); } //Zoom to the parcel when the user clicks a row function onRowClickHandler(evt){ var clickedTaxLotId = grid.getItem(evt.rowIndex).PARCELID; var selectedTaxLot; dojo.forEach(map.graphics.graphics,function(graphic){ if((graphic.attributes) && graphic.attributes.PARCELID === clickedTaxLotId){ selectedTaxLot = graphic; return; } }); var taxLotExtent = selectedTaxLot.geometry.getExtent(); map.setExtent(taxLotExtent); }
Solved! Go to Solution.