Hi,
I am trying to edit existing features in the popup. I put a button in the popup for users to be able to edit and update attributes in the popup fields and save them. I have used FeatureLayer.applyEdits() sample code but it seems my function have some problems. I would appreciate any help.
Solved! Go to Solution.
I'm not sure what you mean. All the attribute data should be in the client if outFields is specified in the feature layer constructor. You don't actually have to use query at all: you can just change the attributes in the client and then call featureLayer.applyEdits({updates:[graphic]}).then(response => console.log(response));
Since you're doing this in the popup window, you have access to a reference to the graphic in popup.viewModel.selectedFeature
I also have this question that based on the functionality matrix, version 4.3 doesn't have AttributeInspector and FeatureEditResult, so can I make my popup editable at all? or it is better to make the expand and use applyEdits for editing features?
Neda,
As those dijits/widgets are yet to come you need to choose the correct API version for your needs. Until the 4.x API becomes mature and contains the AttributeInspector you may have to continue to use the 3.x API.
Choose between version 3.20 and 4.2 | ArcGIS API for JavaScript 4.3
You can absolutely hand code this yourself, but you're going to need to have logic for showing inputs/hiding text when the edit button is clicked and extracting the user input information from the inputs.
Thank you Thomas,
Do I need to set query for each of the attributes separately as well?
I'm not sure what you mean. All the attribute data should be in the client if outFields is specified in the feature layer constructor. You don't actually have to use query at all: you can just change the attributes in the client and then call featureLayer.applyEdits({updates:[graphic]}).then(response => console.log(response));
Since you're doing this in the popup window, you have access to a reference to the graphic in popup.viewModel.selectedFeature