Edit feature attributes with text box

944
3
Jump to solution
11-11-2016 01:38 PM
LindaDunklee
New Contributor III

I am trying to edit existing features in a feature service from JavaScript without making a user click on or draw a feature, to avoid the popup experience.  Has anyone ever committed edits from a text/dropdown box on a web page instead of with the edit widget, and do you have a code sample if so?

Thanks!

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Linda,

   I do editing often not using the edit widget or attribute inspector. I use FeatureLayer.applyEdits method:

https://developers.arcgis.com/javascript/3/jsapi/featurelayer-amd.html#applyedits

I don't have code I can share though as it is a large project that has to do with sensitive secure data.

As you can see from the link though you just pass an array of updated graphics to the applyEdits method. If you are just updating attributes then you would just:

targetGraphic.attributes["some attrib name"] = x;
firePerimeterFL.applyEdits(null, [targetGraphic], null);

View solution in original post

3 Replies
SarojThapa1
Occasional Contributor III

Can you show us your codes so that we could see what you have tried so far?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Linda,

   I do editing often not using the edit widget or attribute inspector. I use FeatureLayer.applyEdits method:

https://developers.arcgis.com/javascript/3/jsapi/featurelayer-amd.html#applyedits

I don't have code I can share though as it is a large project that has to do with sensitive secure data.

As you can see from the link though you just pass an array of updated graphics to the applyEdits method. If you are just updating attributes then you would just:

targetGraphic.attributes["some attrib name"] = x;
firePerimeterFL.applyEdits(null, [targetGraphic], null);
LindaDunklee
New Contributor III

Thanks Robert, that worked beautifully!  A note to anyone else who tries this method on a query result, it won't work if the OBJECTID field is not included in the query output results.  Once I included that there were no issues and the edits committed.

0 Kudos