AnsweredAssumed Answered

Related table in Attribute Inspector

Question asked by thebillcarr on Aug 13, 2014
Latest reply on Aug 16, 2014 by thebillcarr

Greetings,

 

I am having considerable trouble getting the results from a relationship query to populate an attribute inspector(for editing purposes). I have been working on this for a few weeks now and am having no luck.

 

Takes two clicks before the related info will pop up in a infowindow.

 function findRelatedRecords(features) {
        var relatedTopsQuery = new esri.tasks.RelationshipQuery();
        relatedTopsQuery.outFields = ["*"];
        //relatedTopsQuery.relationshipId = 3;
        relatedTopsQuery.relationshipId = 0;
        //relatedTopsQuery.objectIds = [features[0].attributes.OBJECTID];
        relatedTopsQuery.objectIds = [features[0].attributes.OBJECTID];
        wellFeatureLayer.queryRelatedFeatures(relatedTopsQuery, function(relatedRecords) {
          console.log("related recs: ", relatedRecords);
          if ( ! relatedRecords.hasOwnProperty(features[0].attributes.OBJECTID) ) {
            console.log("No related records for ObjectID_1: ", features[0].attributes.OBJECTID_1);
            return;
          }
          var fset = relatedRecords[features[0].attributes.OBJECTID];
          //var fset = relatedRecords[features[0].attributes.OBJECTID];
          items = dojo.map(fset.features, function(feature) {
            return feature.attributes;
          });
          
       

      function findWells(evt) {
  var asdf = evt.layers[0].layer;
          var selectQuery = new Query();
        var selectionQuery = new esri.tasks.Query();
        var tol = map.extent.getWidth()/map.width * 5;
        var x = evt.mapPoint.x;
        var y = evt.mapPoint.y;
        var queryExtent = new esri.geometry.Extent(x-tol,y-tol,x+tol,y+tol,evt.mapPoint.spatialReference);
        selectionQuery.geometry = queryExtent;
        
             asdf.selectFeatures(selectionQuery, FeatureLayer.SELECTION_NEW, function(features) {
             
               //store the current feature
                updateFeature = features[0]; console.log("adf");
                map.infoWindow.setTitle(features[0].getLayer().name); console.log("adf");
                map.infoWindow.show(evt.screenPoint,map.getInfoWindowAnchor(evt.screenPoint)); console.log("adf");
     
            });
            
            
          };
// I am also unable to get the attribute inspector to pull up a non related feature  BELOW
    var layerInfos = [{
            'featureLayer': wellFeatureLayer1,
            'showAttachments': false,
            'isEditable': true,
            'fieldInfos': [
              {'fieldName': 'SERVICE_ID', 'isEditable':true, 'tooltip': 'Current Status', 'label':'Status:'}
            ]
          }];


          var attInspector = new AttributeInspector({
            layerInfos:layerInfos
          }, domConstruct.create("div"));


 

 

Any help would be very much appreciated.

Outcomes