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!
Solved! Go to Solution.
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);
Can you show us your codes so that we could see what you have tried so far?
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);
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.