Select to view content in your preferred language

Using Editor Widget with Auto Update of Attribute

2241
2
12-19-2011 11:51 AM
EricKauffman
Emerging Contributor
Hi all,

I have a simple app that uses the editor widget to add/move/remove points belonging to a feature class. What I need to do is have the application automatically set an attribute value that can't be changed by the user.

I see there are EditCompleted and EditActivated events, but I can't see how I'd use either to manipulate attribute values prior to a feature being saved.

Can someone point me to an example of doing this?

Thanks!
0 Kudos
2 Replies
EricKauffman
Emerging Contributor
Ok, I'm replying to my own thread! Here is how I did this:

On the EditorWidget add a handler to the Edit Completed event.

In the xmal code behind, when you do this, it will automatically create an event handler. Complete the handler using this pattern:

private void MyEditorWidget_EditCompleted(object sender, Editor.EditEventArgs e)
        {
            foreach (Editor.Change change in e.Edits)
            {
                if (change.Graphic.Attributes.ContainsKey("YOUR_COLUMN_NAME"))
                {
                    change.Graphic.Attributes["YOUR_COLUMN_NAME"] = YOUR_NEW_VALUE;
                }
            }
        }
0 Kudos
JenniferNery
Esri Regular Contributor
You might want to check EditAction (i.e. e.Editor.EditAction.Add), your code currently will set the attribute regardless of completed command.

If this is not a concern, you can also use FeatureLayer.BeginSaveEdits event, if any edit should trigger this attribute value change.

Another option is to update your service-defined PrototypeAttributes. EditorWidget contains TemplatePicker that allows you to add features based on feature type. Based on the selected feature type, a list of default attributes are used. This may be related thread: http://forums.arcgis.com/threads/46116-Template-Picker-and-Multiple-Domain-Values-2.3-and-10-SP3
0 Kudos