Edit attributes in popup

2442
5
Jump to solution
06-01-2017 06:35 PM
NedaPeiravian
New Contributor III

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.

0 Kudos
1 Solution

Accepted Solutions
ThomasSolow
Occasional Contributor III

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

View solution in original post

5 Replies
NedaPeiravian
New Contributor III

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?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

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 

ThomasSolow
Occasional Contributor III

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.

NedaPeiravian
New Contributor III

Thank you Thomas,

Do I need to set query for each of the attributes separately as well?

0 Kudos
ThomasSolow
Occasional Contributor III

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