dbecker88

infoTemplate content - relationshipQuery

Discussion created by dbecker88 on Apr 10, 2012
I'm struggling trying to construct a relationshipQuery that populates an infoTemplate

var template = new esri.InfoTemplate();
template.setTitle("${site_code} - ${facil_loca}");
template.setContent(getWindowContent);
  
map.infoWindow.resize(250,250);
    
var facils = new esri.layers.FeatureLayer("https://mydomain.com/MapServer/0",{
        mode:esri.layers.FeatureLayer.MODE_SNAPSHOT,
 infoTemplate:template,
 id: 'facils',
        outFields:["*"]
});


on feature click, getWindowContent() is fired, which constructs the infowindow dijit.layout's

function getWindowContent(graphic){
 //make a tab container 
 var infoTabCont = new dijit.layout.TabContainer({
  style: "width: 100%;height:100%;background-color:transparent;"
 }, dojo.create("div"));
  
 //display attribute info in first tab
 var cp1 = new dijit.layout.ContentPane({
  style: "background-color:transparent;color:White;",
  title: "Details",
  content: "FacID: " + graphic.attributes.site_code + "<br /> Fac Name: " + graphic.attributes.facil_name
 })
  
 //create 2nd tab for related info
 var cp2 = new dijit.layout.ContentPane({
  style: "background-color:transparent;color:White;",
  title: "Cmd Structure",
  content: getRelatedData(graphic) //this is the problem <-----------
 })
  
 //add the content panes to the tab container
 infoTabCont.addChild(cp1);
 infoTabCont.addChild(cp2);
 return infoTabCont.domNode;
}


the content for the second tab fires getRelatedData(), which *should* construct a relationshipQuery and return related data to populate the infowindow tab

function getRelatedData(graphicObj){    
 var objid = graphicObj.attributes.OBJECTID_1
 var relatedFacMain = new esri.tasks.RelationshipQuery();
 relatedFacMain.outFields = ["*"];
 relatedFacMain.relationshipId = 0;
 relatedFacMain.objectIds = [objid];
 graphicObj.queryRelatedFeatures(relatedFacMain, function(relatedRecords) {
  console.log(relatedRecords)
 })
}


on feature click, I get the following warning in firebug: "graphicObj.queryRelatedFeatures is not a function"
I know all the parameters for the relationshipquery are correct, I plugged them into the relationshipquery sample and it works fine.

any advice?

thanks!

Outcomes