Select to view content in your preferred language

Can't disable "Add feature" button in Editor widget

3034
11
Jump to solution
11-19-2021 01:47 PM
BrentGrossman
Occasional Contributor

In my code (using API version 4.18), I'm using a WebScene and WebMap (toggling between 2d and 3d is supported) with many layers. I'd like for users to be able to edit, but not add to, features in one particular feature layer. However, I can't seem to be able to disable the "Add feature" button using addEnabled. Here's my code:

 

        window.locatesFeatureLayer = new this.FeatureLayer({
            url:
                "url to the feature layer in our portal"
        });

        editor = new this.Editor({
                view: view,
                container: editorContainer,
                layerInfos: [{
                    layer: window.locatesFeatureLayer,
                    addEnabled: false
                }]
       });
       editor.addEnabled = false; (//tried to set addEnabled here, too, but 
                                           no luck

 

Here's what the Editor widget looks like when I run my code (it's in an Expand widget, as you can see):

BrentGrossman_0-1637357675821.png

Even if I can disable "Add feature", that's not ideal, since the button is still visible in that case. What I'd really like is to hide or remove that button altogether. 

My questions are,

  1. Why am I not able to disable the "Add feature" button?
  2. Is it possible to hide that button, in addition, or instead of, disabling it?
  3. If the above isn't possible, can I maybe make the Editor window small enough to only show "Edit feature", but then expand that window when the form for editing is visible (after the user has selected a feature to edit)?
  4. If none of the above is possible, can I implement my own editor widget, and if so, what available advice, direction, sample code, etc. is there for doing so?
0 Kudos
11 Replies
ArnoFiva
Esri Contributor

Thanks for the feedback @BrentGrossman and sorry I missed the fact that you also tried to pass addEnabled in the layerInfos. It would be good to see a complete sample as that should work. I've just tried it on the Configurable Editor Widget sample and this is what it looks like:

Using addEnabled on the layerInfos

Screen Shot 2021-11-22 at 3.40.15 PM.png

 

As @Kishore pointed out using allowedWorkflows directly on the Editor

Screen Shot 2021-11-22 at 3.40.50 PM.png

0 Kudos
BrentGrossman
Occasional Contributor

@ArnoFiva, I was able to make "addEnabled: False" work on the Configurable Editor Widget sample, too, by putting it in both layers. My code gets many layers from the portal WebScene that it uses (most of which are not editable), so maybe that's the difference?

"allowedWorkflows" is a perfectly adequate solution for me, but I can probably provide more of my code, if you want to look at it to better understand why "addEnabled" didn't work for me, though I don't think I should post it here.

0 Kudos