Select to view content in your preferred language

Making runtime featureLayers register as datasources for select widget

3400
26
Jump to solution
05-15-2024 01:15 PM
JeffreyThompson2
MVP Frequent Contributor

I am loading my map layers at runtime through a custom widget. Everything is configured as desired in Developer Edition 1.12. Now, I am upgrading to 1.14 primarily for the access to the Select Widget and the Add to Table Data Action.

Adding a data layer with the OOTB Add Data widget will make the layer selectable in the Select Widget, but layers loaded from my custom widget are not available in the Select Widget.

How can I get the Select Widget to recognize the added data? Bonus points, if the Map Layers Widget will also show the Add To Table option.

@Wei_Ying Would creating a client side data source be picked up by the Select Widget? https://github.com/Esri/arcgis-experience-builder-sdk-resources/tree/master/widgets/client-side-outp... Can a single widget have multiple output datasources?

Looking through the code for the Add Data Widget I found these lines.

const dataSourcesChangeMessage = new DataSourcesChangeMessage(widgetId, DataSourcesChangeType.Create, dataSources)
MessageManager.getInstance().publishMessage(dataSourcesChangeMessage)

Could publishing a message similar to this trigger the Select Widget to find the layers?

GIS Developer
City of Arlington, Texas
0 Kudos
26 Replies
QunSun
by Esri Contributor
Esri Contributor

@MohammedHilal_K 

 

Thanks for providing more details. This is a bug and will be fixed in next release.

0 Kudos
JeffreyThompson2
MVP Frequent Contributor

https://community.esri.com/t5/arcgis-experience-builder-questions/loss-of-runtime-created-datasource...

This is a documented bug in Experience Builder 1.15. It is not a problem in 1.14.

GIS Developer
City of Arlington, Texas
0 Kudos
MohammedHilal_K
Occasional Contributor

Hi @JeffreyThompson2 @QunSun 
Am developing custom widget like 'AddData'. So is there any solution to fix this? like updating DataSource again or any other methods? 

0 Kudos
JeffreyThompson2
MVP Frequent Contributor

@MohammedHilal_K Currently, the only workaround is to use Developer Edition 1.14 which does not have this bug.

GIS Developer
City of Arlington, Texas
0 Kudos
MohammedHilal_K
Occasional Contributor

@JeffreyThompson2 @QunSun 

In my custom widget, I'm trying to add multiple layers to the map using the jimuMapView.addOrRemoveDataOnMap(mapData) method. I'm looping through an array and passing mapData to addOrRemoveDataOnMap(). However, the layers are not maintaining the order that I provide.

For example, if the order in my array is [layer1, layer2, layer3], the layers are added to the map in an inconsistent order, like [layer2, layer1, layer3]. Additionally, addOrRemoveDataOnMap does not return a promise, which means I can't use await to control the sequence.

Any suggestions on how to address this issue?

Note: I've also tried passing the complete array to addOrRemoveDataOnMap(mapDatas), but I'm still facing the same issue.

 
0 Kudos
JeffreyThompson2
MVP Frequent Contributor

https://community.esri.com/t5/experience-builder-custom-widgets/add-remove-layers-2-0/ta-p/1540096

I dealt with this problem by building a re-ordering function inside a setTimeout() function.

GIS Developer
City of Arlington, Texas
0 Kudos
MohammedHilal_K
Occasional Contributor

Hi@JeffreyThompson2 @QunSun @YueyangLi @Wei_Ying 

When I add a map service in the above context, the popup does not appear. However, the popup works for feature layers and groups. Any help on this?
Note: If the same map service is configured in Map widget while initial load, that time pop up works.

0 Kudos
YueyangLi
Esri Contributor

@MohammedHilal_K Are you referring to the data action popup? Most data actions (such as export and add to table) are available only for data sources that support queries. Map service data sources do not support queries in ExB.

0 Kudos
MohammedHilal_K
Occasional Contributor

@YueyangLi 
I am referring to the attribute info popup. The DataActions (export & add to table) are working fine, but when we directly click on the map service, the attribute info popup does not display. I have observed this issue even with the out-of-the-box ‘AddData’ widget as well

0 Kudos
YueyangLi
Esri Contributor

@MohammedHilal_K I was able to reproduce the issue and have logged it. Thank you for raising this issue!