contents of popup in a div

367
3
05-25-2022 09:35 AM
LefterisKoumis
Occasional Contributor III

In WAB was able to capture the contents of the popup, customize it and display them in a div.

In JS 4, after a clicking a feature, want to know of how to store all the formatted content from a default popup to a variable so they can be assigned to a div. I don't use popuptemplate because I deal with hundreds of layers with different fields.

So, in a word the task is upon clicking on a feature, capture the popup contents and prevent the display of the default popup, since I will assign it to a div. The  dockoptions not a good option for me.

Tags (1)
0 Kudos
3 Replies
ReneRubalcava
Frequent Contributor

You might want to look at the Feature widget.

https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Feature.html

This is the widget used by the Popup to display the contents. There's a couple of samples linked in that page that show various ways you can use it for displaying the content as you wish.

0 Kudos
LefterisKoumis
Occasional Contributor III

Thank you. The feature widget page states: "The Feature widget displays a graphic according to its PopupTemplate."

Since I don't use popuptemplate, then it wouldn't be applicable to me. All examples use a popuptemplate.  Also, a detail I omitted to mention about my app is that the feature layers on the map are not from web map rather REST services.

I get the default popup displayed at the feature location without using popuptemplate. I am trying to capture the 

view.popup.content  so I can store it in a div.
0 Kudos
ReneRubalcava
Frequent Contributor

Are they always individual graphics in a GraphicsLayer or could you put them in a client-side FeatureLayer? If you put them in a client-side FeatureLayer or they are already FeatureLayers, you can have it create a default PopupTemplate for you.

https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#createPo...

I guess I'm a little confused, if you don't have a PopupTemplate, the layer has no Popup, and there is no content to override? You could do it all manually, using view.hitTest but you would still need a PopupTemplate of some sort for the Popup to display. There is CustomContent for popups you can use too.

0 Kudos