Attribute table widget allowing delete records

4469
14
Jump to solution
07-23-2014 01:25 PM
RhettZufelt
MVP Frequent Contributor

I am using the FV3.6 with the EditWidget and AttributeWidget.  I have the edit widget to only allow attribute updates, no add or delete features, no merge, update, geometry, nothing but <updateattributes>true</updateattributes>.

In the edit widget it appears to honor it.  If I have the edit widget open and click on a feature, the popup allows me to modify the attributes that I have configured, and nothing else.  If the edit widget is open, and I expand the table from the attribute table widget, I can also modify the attributes directly, but only if the edit widget is open (on editable feature layers).  Fine, this is what I was expecting to see.  However, if I have a feature selected in the edit widget, the attribute table widget gives me the option to "Delete Selected features", and if selected WILL delete the feature, even though the edit widget is set to not allow that.

So, where does the attribute table widget get it's options of what it is allowed to do?  Is there a way to make it honor the layer settings so that it is not possible to delete a feature from the attribute table widget?

Also, when I select a feature with the edit widget, it will also select that feature in the attribute table, which is nice.  However, now and then, it doesn't work, and I need to close/re-open the edit widget one to many times (sometimes a refresh of viewer) before it works like that again, and will just select in the edit widget, and not pass the selection on to the attribute table widget.  Any ideas as why this is happening and/or how to fix?

Thanks for any help,


R_

0 Kudos
1 Solution

Accepted Solutions
RhettZufelt
MVP Frequent Contributor

So, at first I thought that the <sublayer iseditable="false"> should remove the delete selected features, but it didn't seem to make a difference, but seems to be working now.  So, if I set the iseditable to false for a particular sublayer, when that layer has a selection in the attribute table, the delete option is no longer shown (though, I can no longer edit the attributes either....).

Would be nice if there were a way to not allow "geometry" edits within the Attribute Table (like you can in the Edit widget) so only the attributes can be changed.  For now, I just made all of them "not" editable in the attribute table, but set to edit attributes only in the Edit widget.

R_

View solution in original post

14 Replies
AnthonyGiles
Frequent Contributor

Rhett,

You could turn off the ability to delete on the actual service in service manager this will ensure that accidental deletes cannot happen. I think this is where the attribute table gets its properties from:

ArcGIS Viewer for Flex

Regards

Anthony

RhettZufelt
MVP Frequent Contributor

Unfortunately, still on 10.0 (don't ask me, not my choice) and that option didn't exist until 10.1.

Looking at the source for AttributeTableOptionsMenu.mxml I see this:


        <s:HGroup id="deleteSelectionGroup"


                  width="100%"


                  buttonMode="true"


                  click="deleteSelectionGroup_clickHandler(event)"


                  enabled="{dataGrid.selectionLength &gt; 0}"


                  includeInLayout="{showDeleteOption}"


                  verticalAlign="middle"


                  visible="{showDeleteOption}">

and in the AttributeTableSkin.mxml:


            private function updateOptions(featureLayer:FeatureLayer):void
            {
                dataGrid.editable = isFeatureLayerUpdateAllowed(featureLayer);


                optionsMenu.showZoomToSelectionOption = featureLayer.map && featureLayer.layerDetails;
                optionsMenu.showDeleteOption = isDeleteOptionShown(featureLayer);
                optionsMenu.showAttachmentsOption = isAttachmentsOptionShown(featureLayer);
                optionsMenu.showRelatedRecordsOption = isRelatedRecordsOptionShown(featureLayer);
            }

Yet I can't figure out where showDeleteOption is set????   Any ideas?

Thanks again,

R_

DanielSmith
Occasional Contributor III

a simple option would be the change the attributeTable_deleteFeaturesHandler to through a pop up that indicates features can not be deleted and remove the part that actually deletes the record.

private function attributeTable_deleteFeaturesHandler(event:AttributeTableEvent):void

            {

                const deletes:Array = event.features;

                event.featureLayer.applyEdits(null, null, deletes, false,

                                              new AsyncResponder(featureLayer_editsCompleteHandler, featureLayer_faultHandler, { featureLayer: event.featureLayer }));

            }

to

private function attributeTable_deleteFeaturesHandler(event:AttributeTableEvent):void

            {

               Alert.show("Records can not be deleted")

            }

RhettZufelt
MVP Frequent Contributor

Thanks for the idea, however, that would leave it there when there is a selection, and would appear as if you could delete something until you try, then get the error message.  In this case, the delete option would never work.

So, looking into it more, I am assuming that the variable showDeleteOption is set in the API when a selection is made or cleared as I can't find it anywhere in the available source other than when it is called in the skins (yet the options disappears when there is no selection, so has to be dynamic somewhere).

So, for now, I'm going to try something like this since the options I can think of disable it permanently:

<s:HGroup id="deleteSelectionGroup" 

    width="100%" 

   buttonMode="true" 

   click="deleteSelectionGroup_clickHandler(event)" 

   enabled="{dataGrid.selectionLength &gt; 0}" 

   includeInLayout="False" 

   verticalAlign="middle" 

   visible="False"> 

This should just remove the delete option permanently so it isn't available.  Figure if I need to be able to delete features, I can enable that in the edit widget itself.

R_

DanielSmith
Occasional Contributor III

weird... i don't see those files... would you mind posting full path to there location within in the flex project.

0 Kudos
RhettZufelt
MVP Frequent Contributor

They are here:

\src\com\esri\ags\skins\supportClasses

\src\com\esri\ags\skins

DanielSmith
Occasional Contributor III

hmmmm.....i think im going crazy as I can not find these in flash builder.. whats going on here?

0 Kudos
AnthonyGiles
Frequent Contributor

Daniel,

You will only have the skins folders if you have downloaded the flex API not just the viewer API:

ArcGIS API for Flex | ArcGIS for Developers

DanielSmith
Occasional Contributor III

totally. many thanks for the seedy response

0 Kudos