"No Features Selected" with Multiple Attribute Inspectors

1030
2
Jump to solution
05-14-2014 04:08 PM
Town_ofSnowflake
Occasional Contributor
I have a map with a single point layer for which I've assigned an Attribute Inspector with a custom "Edit Button". When the layer is clicked, the Attribute Inspector displays properly:

[ATTACH=CONFIG]33825[/ATTACH]

When the edit button is clicked, I have an "EditMode" function, which should display an Attribute Inspector. This time with editable fields. When the 2nd Attribute Inspector's info window is displayed, "No Features Selected" is displayed in the content rather than a list of editable fields. Any ideas why is this happening?

[ATTACH=CONFIG]33826[/ATTACH]

I'm using the Multiple Attribute Inspectors Sample as a guide.

Once the feature layer (globals.eventsMSL) has been added, initInfoWindow adds the Attribute Inspector to my globals.eventsMSL layer:


 function initInfoWindow(results){       console.log("in the initInfoWindow function: " + globals.map.layerIds.length);      globals.query = new Query();   globals.eventsMSL.on("click", function(evt){    if (globals.map.infoWindow.isShowing) {     globals.map.infoWindow.hide();    };     var layerInfos = [{     'featureLayer': globals.eventsMSL,     'isEditable': false,     'showAttachments': false,     'showDeleteButton':false    }]     var attInspector = new esri.dijit.AttributeInspector({     layerInfos: layerInfos    }, dojo.create("div"));     globals.query.objectIds = [evt.graphic.attributes.OBJECTID];     globals.eventsMSL.selectFeatures(globals.query, FeatureLayer.SELECTION_NEW, function(features){     globals.map.infoWindow.setTitle("");     globals.map.infoWindow.setContent(attInspector.domNode);     globals.map.infoWindow.resize(350, 240);     globals.map.infoWindow.show(evt.screenPoint, globals.map.getInfoWindowAnchor(evt.screenPoint));                           var editButton = new Button({              label: "Edit",              "class": "editButton"             });              domConstruct.place(editButton.domNode, attInspector.deleteBtn.domNode, "after");              editButton.on("click", function() {         editMode(features);    });         });    });   }


The "EditMode" Function should display an Attribute Inspector:
  function editMode(features){      if (globals.map.infoWindow.isShowing) {     globals.map.infoWindow.hide();    }    var layerInfos = [{     'featureLayer': globals.eventsMSL,     'isEditable': true    }];      var attInspector = new esri.dijit.AttributeInspector({     layerInfos: layerInfos    }, dojo.create("div"));         var editScreenPoint = globals.evt.screenPoint;    globals.map.infoWindow.setContent(attInspector.domNode);    globals.map.infoWindow.resize(325, 185);     globals.map.infoWindow.show(editScreenPoint, globals.map.getInfoWindowAnchor(editScreenPoint));      attInspector.on("delete", function(evt) {         globals.map.infoWindow.hide();    });     attInspector.on("attribute-change", function(evt) {        });    }
0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable
Original User: andygup

Hi,

The way the AttributeInspector works is:
1. Create a new AttributeInspector
2. Programmatically select features on the FeatureLayer.
3. Display popup using AttributeInspector's domNode

When you click the "edit" button the editMode() code is only doing steps 1 and 3. The new AttributeInspector you created doesn't inherit the selected features from the previous AttributeInspector. And, that's why you are getting the no features selected message.

You'll need to programmatically re-select the appropriate feature and then your edit AttributeInspector should work.

-Andy

View solution in original post

0 Kudos
2 Replies
by Anonymous User
Not applicable
Original User: andygup

Hi,

The way the AttributeInspector works is:
1. Create a new AttributeInspector
2. Programmatically select features on the FeatureLayer.
3. Display popup using AttributeInspector's domNode

When you click the "edit" button the editMode() code is only doing steps 1 and 3. The new AttributeInspector you created doesn't inherit the selected features from the previous AttributeInspector. And, that's why you are getting the no features selected message.

You'll need to programmatically re-select the appropriate feature and then your edit AttributeInspector should work.

-Andy
0 Kudos
Town_ofSnowflake
Occasional Contributor
Thanks, Andy. That worked. For documenting purposes, below is my fixed "EditMode" function.

In the following order (order matters):
1. Created the new Attribute Inspector
2. Re-selected the feature
3. Displayed the popup

function editMode(features){
   var layerInfos = [{
    'featureLayer': globals.eventsMSL,
    'isEditable': true
   }];

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

   globals.eventsMSL.selectFeatures(globals.query, FeatureLayer.SELECTION_NEW, function(editFeatures){

    if (globals.map.infoWindow.isShowing) {
     globals.map.infoWindow.hide();
    }

    var editScreenPoint = globals.map.toScreen(editFeatures[0].geometry);
    globals.map.infoWindow.setContent(attInspector.domNode);
    globals.map.infoWindow.resize(325, 185);

    globals.map.infoWindow.show(editScreenPoint, globals.map.getInfoWindowAnchor(editScreenPoint));


    attInspector.on("delete", function(evt) {

     globals.map.infoWindow.hide();
    });

    attInspector.on("attribute-change", function(evt) {

    });

   });

  }
0 Kudos