I have looked through numerous postos on this, but I cannot seem to solve my problem.
The attributes are not populating my datagrid. If I use BJECTID or my GlobalID for the features the datagrid populates with that information, but no other attributes. The ZOOM to feature even works.
Any assistance would br greatly appreciated
Thank you.
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=7, IE=9"> <!--The viewport meta tag is used to improve the presentation and behavior of the samples on iOS devices--> <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"> <title>911 Research</title>
//Create the find parameters findParams = new esri.tasks.FindParameters(); findParams.returnGeometry = true; findParams.layerIds = [0]; findParams.searchFields = ["FULLADDR"]; }
function doFind() { //Set the search text to the value in the box findParams.searchText = dojo.byId("searchText").value; 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.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_DIAMOND, 10, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([0, 0, 0]), 1), new dojo.Color([255, 255, 0, 1]));
//Create items array to be added to store's data var items = []; //all items to be stored in data store for (var i = 0, il = results.length; i < il; i++) { items.push(results.feature.attributes); //append each attribute list as item in store var graphic = results.feature;
//variable for the point extent var pt = graphic.geometry;
//Create data object to be used in store var data = { identifier: "GlobalID", //This field needs to have unique values label: "GlobalID", //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 }); grid.setStore(store); grid.setQuery({ GlobalID: '*' });
//Zoom back to the initial map extent map.setExtent(startExtent);
}
//Zoom to the parcel when the user clicks a row function onRowClickHandler(evt) { var clickedGlobalID = grid.getItem(evt.rowIndex).GlobalID; var selectedAddress; for (var i = 0, il = map.graphics.graphics.length; i < il; i++) { var currentGraphic = map.graphics.graphics; //variable for the point extent //var pt = graphic.geometry; if ((currentGraphic.attributes) && currentGraphic.attributes.GlobalID == clickedGlobalID) { selectedAddress = currentGraphic; break; } } //add this code to set the point extent and zoom in var PointExtent = new esri.geometry.Extent(); PointExtent.xmin = selectedAddress.geometry.x - 5; PointExtent.ymin = selectedAddress.geometry.y - 5; PointExtent.xmax = selectedAddress.geometry.x + 5; PointExtent.ymax = selectedAddress.geometry.y + 5;
I found the issue myself. It turns out that the attribute field names are not what I assumed they were. I did not realize this until I ran a FIND in my rest service.