In the Web Appbuilder Developer Edition, say I want to open a widget which is not in a controller but in a place holder. How can I manage that ?
I've tried using the WidgetManager openWidget(widget) followed by PanelManager showPanel() functions but it only works if the widget has already been opened once before (manually).
Solved! Go to Solution.
Mathieu,
I have no problem at all opening a widget in a onscreen placeholder that has not been opened yet using these two lines of code only from inside another widget.
var pm = PanelManager.getInstance(); pm.showPanel(this.appConfig.widgetOnScreen.widgets[4]);
Mathieu,
I have no problem at all opening a widget in a onscreen placeholder that has not been opened yet using these two lines of code only from inside another widget.
var pm = PanelManager.getInstance(); pm.showPanel(this.appConfig.widgetOnScreen.widgets[4]);
Robert,
for on screen widget that is not visible and not started, I tried this but it does not open the widget
var wm =WidgetManager.getInstance();
wm.openWidget("widgets_BufferSelection_53");
The widgets_BufferSelection_53 is the widget id as identified in the config.json
Thanks.
Lefteris,
Did you try that code that is marker as the answer?
Yes, I did. It never open the widget.
Lefteris,
I just tried these two lines of code again and they worked flawlessly:
var pm = PanelManager.getInstance();
pm.showPanel(this.appConfig.widgetOnScreen.widgets[4]);
Hmm. I am wondering what do I do wrong.
config.json:
"widgetOnScreen": {
"widgets": [
{
"uri": "widgets/BufferSelection/Widget",
"version": "1.3",
"id": "widgets_BufferSelection_53",
"name": "BufferSelection",
"label": "Buffer Selection",
"openAtStart": false
},
.............
widget.js of another widget that calls the Buffer Selection
.........
var pm = PanelManager.getInstance();
pm.showPanel(this.appConfig.widgetOnScreen.widgets["widgets_BufferSelection_53"]);
........
and I get the error:
Cannot read property 'id' of undefined for the second line above
Lefteris,
Because the pm.showPanel function is expecting the the whole widget configuration object and this.appConfig.widgetOnScreen.widgets["widgets_BufferSelection_53"] is not doing that. what is the index (i.e. postilion number) of the widgets_BufferSelection_53 in the widgetOnScreen widget array?
Once you figure that out then use that number as below:
pm.showPanel(this.appConfig.widgetOnScreen.widgets[0]);
A childish mistake. I assumed that the parameter in the this.appConfig.widgetOnScreen.widgets is the widget id and I didn't notice the array.
Yes, it works now. However, when the Buffer Selection widget opens it closes the widget that calls it. How can I retain both widgets visible?
Thank you.
Lefteris,
Depends on the theme you are using. Most themes are only permited to have on widget open at a time. But the Launchpad theme allows for multiple to be open and you can have a on screen and a widget in the side panel of the foldable theme open at the same time.