Currently we are having a FeatureLayer (Grid) which refers to a table. This feature layer stores the ID which is the foreign key of the other table.I want to fetch data from the other table using IDs from this feature layer. Does anybody know how to use Query/RelationshipQuery to fetch data and present it in the infowindow of the Map ?here is what i have : var Grid = new FeatureLayer("http://gisdev2.dickinson.edu/arcgis/rest/services/Pasture_Data/WebMap/FeatureServer/1", {
mode: FeatureLayer.MODE_SELECTION,
outFields: ["GridID"]
});
map.addLayers([Grid]);
//map.addLayers([RandomPointFL]);
function initSelectToolbar(evt) {
var Grid = evt.layers[0].layer;
var selectQuery = new Query();
map.on("click", function(evt) {
selectQuery.geometry = evt.mapPoint;
selectQuery.objectIds = [features[0].attributes.OBJECTID];
var relatedQuery = new RelationshipQuery();
relatedQuery.outFields = ["GridID"];
relatedQuery.relationshipId = 4;
selectQuery.outFields = ["GridID"];
var content;
Grid.queryFeatures(selectQuery, function(features) {
if (features.length >= 0) {
//store the current feature
//graphicAttributes = evt.graphic.attributes;
//title = graphicAttributes.req_type;
content = "<b>GridID: </b>" + features;
updateFeature = features[0];
map.infoWindow.setTitle(features[0].getLayer(1).name);
map.infoWindow.setContent(content);
map.infoWindow.show(evt.screenPoint,map.getInfoWindowAnchor(evt.screenPoint));
console.log(features[0]);
} else {
map.infoWindow.hide();
}
});
});