I need to reset all the values in a field for all the features in a feature service. Just like the field Calculator in ArcMAP. Basically push a button and a whole field gets reset?
Any ideas?
Solved! Go to Solution.
In one of my apps, I use applyEdits to update a collection of features (featureSet) with the click of a button. The user selected the new attributes from a series of combo boxes and clicked the button. In the button click function, my code looked like this
array.forEach(featureSet, function (feature) {
feature.attributes.Priority = registry.byId('cboPriority').get("value");
feature.attributes.Management = registry.byId('cboManagement').get("value");
feature.attributes.Criteria = registry.byId('cboCriteria').get("value");
});
layerFeatureLayer.applyEdits(null, featureSet, null, function () { console.log("Features updated!"); }, function (error) { console.log("Features not updated! ", error); });
Paul,
This is not something that can be easily done in JS API. Your possibilities are to use FeatureLayer.applyEdits or create a GP service fro this.
Thanks For the Reply Robert,
With the FeatureLayer.applyEdits is there a way to do all of the features at once or will I have to do each OBJECTID individually?
Paul,
You have to provide an array containing each graphic (that is why I said that this is not easily done with JS API);
In one of my apps, I use applyEdits to update a collection of features (featureSet) with the click of a button. The user selected the new attributes from a series of combo boxes and clicked the button. In the button click function, my code looked like this
array.forEach(featureSet, function (feature) {
feature.attributes.Priority = registry.byId('cboPriority').get("value");
feature.attributes.Management = registry.byId('cboManagement').get("value");
feature.attributes.Criteria = registry.byId('cboCriteria').get("value");
});
layerFeatureLayer.applyEdits(null, featureSet, null, function () { console.log("Features updated!"); }, function (error) { console.log("Features not updated! ", error); });
That worked! Thanks Ken!
Did a query to select all features then ran that array. Thank you