Change label of Delete button in Attribute inspector

3425
5
01-20-2014 06:24 AM
AleydisG__Pere
Occasional Contributor
The thread title says it all.
I want to change the label of the Delete button in the Attribute inspector to 'Dismiss'. As that label has more sense in the context of my application.
Is this possible?
0 Kudos
5 Replies
JonathanUihlein
Esri Regular Contributor
Yep!

https://developers.arcgis.com/en/javascript/jssamples/ed_attribute_inspector.html

Starting at version 2.2, you can customize the fields in the attribute  inspector by specifying field information as part of the layer infos  object.


As for the button:
dijit.byId("dijit_form_Button_0").set("label", "Dismiss");


*edit

"dijit_form_Button_0" is the widgetid; grabbed from the demo above using firebug but you can always set your own.
0 Kudos
RowenaTansley1
New Contributor III

How do you set the ID of the delete button in the attribute inspector? Thanks!

0 Kudos
AleydisG__Pere
Occasional Contributor
My application is similar to this other sample where your suggestion won't work as a new button is created each time I click on the map to add a new feature.
😞
0 Kudos
AleydisG__Pere
Occasional Contributor
As I use 2 attribute inspectors (one is read only). Every time I query a feature in the map a new attribute inspector widget is created (esri_dijit_AttributeInspector_0, esri_dijit_AttributeInspector_1, esri_dijit_AttributeInspector_2,....) and therefore I can't change its Delete button label, because its id is different every time too (dijit_form_Button_0, dijit_form_Button_8, dijit_form_Button_16,...).
I've tried destroying the attr. inspector widget with the destroy() method so every time it's recreated it has the same id, i.e. esri_dijit_AttributeInspector_0, (and also the buttons in it) but to no avail. I've also tried with this, but it doesn't work:
dijit.registry.byId("esri_dijit_AttributeInspector_0").destroy();
dijit.registry.remove("esri_dijit_AttributeInspector_0");


I don't know if this code behavior should be avoided. Do I only have an attribute inspector widget each time, only that with different label, or am I keeping each one created? ?_?
I'd like to find it out but meanwhile what I'm doing is hide the widget's 'Detele' button and create my own 'Dismiss' button. Any code improvement is welcome. 😉
Here's my code:
    var layerInfos = [{
      'featureLayer': featLayer,
      'isEditable': true,
      'showAttachments':false,
      'showDeleteButton':false,
      'disableAttributeUpdate':false,
      'disableGeometryUpdate': true 
    }];
     
    attInspector = new esri.dijit.AttributeInspector({
      layerInfos: layerInfos
    }, dojo.create("div"));
    
    //selectedTemplate is the selected template picked by the user
    selectedTemplate.featureLayer.applyEdits([newGraphic], null, null, function() {
      var screenPoint = map.toScreen(getInfoWindowPositionPoint(newGraphic));
      map.infoWindow.setTitle("Incident about " + featLayer.name);
      map.infoWindow.setContent(attInspector.domNode);
      map.infoWindow.resize(260, 265);
      map.infoWindow.show(screenPoint, map.getInfoWindowAnchor(screenPoint));
      templatePicker.clearSelection();
    }); 
 
    var DismissButton = new dijit.form.Button({ label: "Dismiss", "class": "deleteButton"});
    var DoneButton = new dijit.form.Button({ label: "Done", "class": "closeButton"});
    dojo.place(DismissButton.domNode,attInspector.deleteBtn.domNode, "before")
    dojo.place(DoneButton.domNode, DismissButton.domNode, "after");

    dojo.connect(attInspector, "onAttributeChange", function(feature, fieldName, newFieldValue) {
      feature.attributes[fieldName] = newFieldValue;
      feature.getLayer().applyEdits(null, [feature], null);
    });
           
    DoneButton.on("click", function(){
      map.infoWindow.hide();       
    });
    
    DismissButton.on("click", function(){
      featLayer.applyEdits(null, null, [newGraphic]);
      map.infoWindow.hide();
    });
0 Kudos
RowenaTansley1
New Contributor III

Hi, did either of you find solutions to your problems? I am embarking down a similar path, modifying the attribute inspector, and creating and modifying buttons, curious if either of you have any tips for dealing with the attribute inspector and it's buttons? Thanks!

Also, I  did try the  sample posted above, and can't seem to place the save button correctly, it overlaps the delete button.

          var saveButton = new Button({ label: "Save", "class": "saveButton"},domConstruct.create("div"));
          domConstruct.place(saveButton.domNode, attInspector.deleteBtn.domNode, "after");
0 Kudos