How can I get custom field value from popup selected index features if field visibility is false in popup fieldInfos? (arcgis-js-api 4.12)

990
7
Jump to solution
09-09-2020 12:45 AM
ShefaliMantri
New Contributor III

I create a feature layer from external service(JSON data). All the fields of the feature layer display in the popup. There is one custom field i.e. for eg 'Test_id' which has a unique value for each feature(not ObjectId). When I open any popup I get a selected index popup feature and from that feature/attributes, I fetch the 'Test_id' field value to perform some action. If I set field visibility false in the popup field Infos then in popup features I am not getting that field but I want that field to perform some logic and at the same time I want that field is not displayed in the popup UI.

Issues: If I set field visibility false in the popup field Infos then in popup features I am not getting that field.

Question: How can I get the 'Test_id' field value from popup selected index features if field visibility is false in the popup fieldInfos? If visibility is true in the popup field Infos then how to display none for that field in the popup UI

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Esteemed Contributor

This sample shows how to define the fields of the popup but the content is set by a function which creates the text using the features attributes. So you can set the popups content and choose not to use your test_id field in the popups content.

https://developers.arcgis.com/javascript/latest/sample-code/sandbox/index.html?sample=popuptemplate-... 

View solution in original post

7 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

This sample shows how to define the fields of the popup but the content is set by a function which creates the text using the features attributes. So you can set the popups content and choose not to use your test_id field in the popups content.

https://developers.arcgis.com/javascript/latest/sample-code/sandbox/index.html?sample=popuptemplate-... 

ShefaliMantri
New Contributor III

Ok if that field is not in popup content then should I get that field value in mapView.popup.features[mapView.popup.selectedFeatureIndex]

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

mapView.popup.selectedFeature.attributes.YourFieldName

0 Kudos
ShefaliMantri
New Contributor III
Thanks for the response,
 
Our requirement is to display all fields in popup except 'Test_id' therefore looping for fields may not be the optimal solution as we have 40+ fields belonging to several layers.
  
Our intent is to have a solution that can hide the visibility of 'Test_id' on popup UI only and at the same time we want to use it in the background processing(i.e. get in mapView.popup.selectedFeature), could you suggest any other solution
0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Nope. Your requirements need to conform to methods available.

0 Kudos
ShefaliMantri
New Contributor III

Thanks popup content solution worked.

One thing which i observed if pagination in popup template(multiple features) and i zoom in map then on click of next in popup pagination, popup pointer not change to selected index feature position.

Question:- Why popup anchor pointer not changing to selected feature on click of next/previous in popup pagination.

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

I have not run into that. But maybe look at this link and the "updateLocationEnabled" property

https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#open 

0 Kudos