WAB - update NearMe widget configuration programmaticlly

38
0
10-04-2022 07:18 AM
Labels (1)
GISiste
New Contributor III

Web AppBuilder 2.21 Developer Edition

Hey all,

I'm trying to change the configuration of the NearMe widget. I've generated both of the config files from WAB. I tested the widget with each file and is working fine. Now, I did'nt want to duplicate the widget and I would like to alternate bitween the two configurations. I've added two radio buttons to handle the user action.

Here a snnipt of my code

function changeConfig(PanelManager, WidgetManager) {
let mywidget = PanelManager.getInstance().widgetManager.loaded.filter((item) => {return item.name == 'NearMe'});
const button1 = document.getElementById('button1')
const button2 = document.getElementById('button2')
button1 && button1.checked ? mywidget[0].config = config1 : null;
button2 && button2.checked ? mywidget[0].config = config2 : null;
console.log(mywidget[0])
//destroy the widget with olde config
WidgetManager.getInstance().destroyWidget(mywidget[0])
//start the widget with the new config
mywidget[0].startup()
}

 

Is there any chance to do that ? I saw a related answer here https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-modify-widget-config-pr...
that would not possible but still trying to get that worked ...

 

Thanks a lot

 

Tags (2)
0 Kudos
0 Replies