Edit Only Attributes of Selected Feature

1020
10
09-12-2018 08:43 AM
MarkBushyeager
New Contributor III

I'm trying to create a Web App that will allow users to modify only one attribute of a feature that identifies the status of the feature (e.g. "in progress", "completed").  The edit widget allows me to do that but because I'm not using a feature template, when you click on the widget button, the dialog box indicates there are not editable features, even though the user can edit the attribute. I'm afraid the dialog box will mislead users.  Is there anyway to disable the dialog box on the edit widget or some other simple way to edit only the attributes of a selected feature?  I looked briefly at batch attribute editor, but this doesn't seem to be the way to go.

0 Kudos
10 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Mark,

   Are you only going to allow the user to edit the attribute and never add a new feature?

0 Kudos
MarkBushyeager
New Contributor III

Yes, only edit a single attribute of existing features

0 Kudos
MarkBushyeager
New Contributor III

I figured it out. The "Smart Editor" widget was just what I needed.

0 Kudos
MichaelVolz
Esteemed Contributor

Can you provide an explanation of what you did to get the Smart Editor widget to do what you wanted?

0 Kudos
MarkBushyeager
New Contributor III

Michael, after playing with it a bit, the Smart Editor isn't perfect in that it also provides a misleading dialog box, but it is more intuitive than the edit widget and I can live with it.  Before using the web app builder, I created a map in ArcGIS online using a single feature service.  I restricted editing on the service to the one attribute that I want users to be able to change.  When I created the Web App using Web AppBuilder, the restrictions carry through.  I simply added the Smart Editor Widget and it accomplished the goal (mostly).  Ken's posting below indicates that this is a known problem.

MichaelVolz
Esteemed Contributor

Mark:

2 questions:

1.) If ESRI fixes the bug with the Edit Widget, would you update your app to use the Edit Widget or stay with the Smart Editor widget?

2.) Can you point me to documentation on how to restrict editing on a service to just 1 attribute?

0 Kudos
KenBuja
MVP Honored Contributor

When you configure the Edit widget, you can set the fields to be edited. I don't know why these don't carry over from the web map, however.

Each layer in the web map is shown in the table at the bottom of the configuration dialog. Move your mouse over the Fields column for a specific layer and click the Edit icon. This brings up the "Configure layer fields" dialog where you can select the fields that will be displayed and can be edited.

KenBuja
MVP Honored Contributor

I had noticed a similar issue. In my case, I have a hosted feature service set to "Update attributes only". When the user starts the editing process, the Edit widget shows the message "Your account does not have permission to create or modify data. Or this web map does not contain any editable layers."

I talked with Esri support about this and they came back with this:

After some further testing, the error message goes away when feature creation is enabled on the feature layer because a feature template is then populated. If feature creation is disabled (as it is when "Update Attributes Only" or "Update features" is set as the editing type), no feature template is required. But instead of simply stating that, the error message that is returned is inaccurate and misleading. This is only occurs in the Edit widget; the message when editing without feature creation enabled in the web map is a bit less misleading. It reads "Feature creation has been disabled for this layer." There's no way to get rid of the message except to enable feature creation, which I know isn't an option for you.

They logged a bug (#BUG-000115038), but it has a low severity.

RobertScheitlin__GISP
MVP Esteemed Contributor

Mark,

  If you want the edit widget to not display that message then you can make this simple change to the edit widget.js _worksAfterCreate function (lines 45 and 46).

      _worksAfterCreate: function(settings) {
        // add button to atiInspector
        this._addButtonToInspector();

        // disable delete button in the toolbar
        if(this._configEditor.toolbarVisible) {
          this._disableDeleteBtnInToolbar();
        }

        // resize editPopup
        this.editPopup.resize(500, 251);
        // update templatePicker for responsive.
        this.editor.templatePicker.update(true);
        // // reset default selectionSymbol that change by Editor dijit.
        // array.forEach(this.editor.settings.layerInfos, function(layerInfo) {
        //   layerInfo.featureLayer.setSelectionSymbol();
        // }, this);

        // add FilterEditor
        this._addFilterEditor(settings);

        // bind events after create.
        this._bindEventsAfterCreate(settings);

        // udpate templatePicker's message.
        this._changeMessageForTemplatePicker();

        // prepare attributeInspector loading shelter
        this.ATILoading = new LoadingShelter({
          hidden: true
        }).placeAt(this.editor.attributeInspector.domNode);

        // work around for bug of editor's selectionHelpler,
        this.editor.own(aspect.before(this.editor._selectionHelper,
                      'selectFeatures',
                      lang.hitch(this.editor._selectionHelper, function(layers, query, selectionMethod, callback) {
          var newLayers = array.filter(layers, function(layer) {
            if(layer.visible === true && layer._isMapAtVisibleScale() === true) {
              return true;
            }
          });
          return [newLayers, query, selectionMethod, callback];
        })));

        html.setStyle(this.editor.templatePicker.domNode, 'display', 'none');
        this.editWidgetTitle.innerHTML = '';

        // must be called at end of the _worksAfterCreate.
        this._createOverDef.resolve();
      },