<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to programmatically open a widgetOnScreen widget in Web AppBuilder Custom Widgets Questions</title>
    <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-programmatically-open-a-widgetonscreen/m-p/796570#M4689</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a similar problem. My widget isn't widgetOnScreen. Rather, I need to programmatically load and open a widget that was controller by the header widget. So, I had to load the widget, and also open the panel. Here's what I've got so far:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;var wm = WidgetManager.getInstance(); 
var myWidget = null; 
arrayUtils.some(wm.appConfig.widgetPool.widgets, function(aWidget) {
&amp;nbsp; if(aWidget.id == 'somewidgetid') {
&amp;nbsp;&amp;nbsp;&amp;nbsp; myWidget = aWidget;
&amp;nbsp;&amp;nbsp;&amp;nbsp; return true;
&amp;nbsp; }
&amp;nbsp; return false;
}); 
wm.loadWidget(myWidget); 
wm.openWidget(myWidget); 
var pm = PanelManager.getInstance(); 
pm.showPanel(myWidget);&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will open the widget in the panel. Unfortunately, it opens my widget as a NEW widget, rather than activating the widget in the header controller. I can tell because the widget icon, in the header, is not toggled.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It's a step in the right direction. But hopefully this will bump someday else to contribute to the thread.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 09:12:03 GMT</pubDate>
    <dc:creator>deleted-user-Jie3eyjOl9XM</dc:creator>
    <dc:date>2021-12-12T09:12:03Z</dc:date>
    <item>
      <title>How to programmatically open a widgetOnScreen widget</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-programmatically-open-a-widgetonscreen/m-p/796569#M4688</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Let's say I put the Basemap Gallery widget in the widgetOnScreen section of the main config.json. How do I programmatically open it?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This code does not work:&lt;/P&gt;&lt;P&gt;PanelManager.getInstance().showPanel(WidgetManager.getInstance().appConfig.widgetOnScreen.widgets[4])&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any insight would be helpful,&lt;/P&gt;&lt;P&gt;Thanks, Matt English&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Oct 2014 15:54:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-programmatically-open-a-widgetonscreen/m-p/796569#M4688</guid>
      <dc:creator>MapEnglish</dc:creator>
      <dc:date>2014-10-14T15:54:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to programmatically open a widgetOnScreen widget</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-programmatically-open-a-widgetonscreen/m-p/796570#M4689</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a similar problem. My widget isn't widgetOnScreen. Rather, I need to programmatically load and open a widget that was controller by the header widget. So, I had to load the widget, and also open the panel. Here's what I've got so far:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;var wm = WidgetManager.getInstance(); 
var myWidget = null; 
arrayUtils.some(wm.appConfig.widgetPool.widgets, function(aWidget) {
&amp;nbsp; if(aWidget.id == 'somewidgetid') {
&amp;nbsp;&amp;nbsp;&amp;nbsp; myWidget = aWidget;
&amp;nbsp;&amp;nbsp;&amp;nbsp; return true;
&amp;nbsp; }
&amp;nbsp; return false;
}); 
wm.loadWidget(myWidget); 
wm.openWidget(myWidget); 
var pm = PanelManager.getInstance(); 
pm.showPanel(myWidget);&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will open the widget in the panel. Unfortunately, it opens my widget as a NEW widget, rather than activating the widget in the header controller. I can tell because the widget icon, in the header, is not toggled.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It's a step in the right direction. But hopefully this will bump someday else to contribute to the thread.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 09:12:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-programmatically-open-a-widgetonscreen/m-p/796570#M4689</guid>
      <dc:creator>deleted-user-Jie3eyjOl9XM</dc:creator>
      <dc:date>2021-12-12T09:12:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to programmatically open a widgetOnScreen widget</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-programmatically-open-a-widgetonscreen/m-p/796571#M4690</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here are some functions I have written to programatically open widgets:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;// For widgets not in a panel that are not loaded at startup, load and return the widget.
_getWidget: function(widgetCfg, start) {
&amp;nbsp; var def = new Deferred();
&amp;nbsp; var widget;

&amp;nbsp; if (widgetCfg) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; // Try getting the widget
&amp;nbsp;&amp;nbsp;&amp;nbsp; widget = registry.byId(widgetCfg.id);

&amp;nbsp;&amp;nbsp;&amp;nbsp; if (widget) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; def.resolve(widget);
&amp;nbsp;&amp;nbsp;&amp;nbsp; } else {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.widgetManager.loadWidget(widgetCfg).then(function(widget) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (start) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; widget.startup();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; def.resolve(widget);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp; } else {
&amp;nbsp;&amp;nbsp;&amp;nbsp; def.resolve(undefined);
&amp;nbsp; }
&amp;nbsp; return def;
},&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;_getWidget(widgetCfg, start) will return a widget for widgets not in panels.&amp;nbsp; An example of widgetCfg is WidgetManager.getInstance().appConfig.widgetOnScreen.widgets[4].&amp;nbsp; If start is true, the widget will be started.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;// For in panel widgets that are not loaded at startup, load and return the widget.
_getPanel: function(widgetCfg, start) {
&amp;nbsp; var def = new Deferred();
&amp;nbsp; var panel;
&amp;nbsp; 
&amp;nbsp; if (widgetCfg) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; // Try getting the panel for this widget
&amp;nbsp;&amp;nbsp;&amp;nbsp; panel = registry.byId(widgetCfg.id + '_panel');

&amp;nbsp;&amp;nbsp;&amp;nbsp; if (panel) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; def.resolve(panel);
&amp;nbsp;&amp;nbsp;&amp;nbsp; } else {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.panelManager.showPanel(widgetCfg).then(function(panel) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (start) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; panel.startup();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; def.resolve(panel);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp; } else {
&amp;nbsp;&amp;nbsp;&amp;nbsp; def.resolve(undefined);
&amp;nbsp; }
&amp;nbsp; return def;
},&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;_getPanel(widgetCfg, start) will return a panel (which contains the widget) for widgets in panels.&amp;nbsp; An example of widgetCfg is WidgetManager.getInstance().appConfig.widgetOnScreen.widgets[4].&amp;nbsp; If start is true, the widget will be started.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;// For widgets that are loaded at startup, return the widget when it is available.
&lt;SPAN&gt;// Recursive Deferred from &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://developer.the-hideout.de/?p=125" rel="nofollow noopener noreferrer" target="_blank"&gt;http://developer.the-hideout.de/?p=125&lt;/A&gt;
_getWidgetWhenLoaded: function(id, wait, count) {
&amp;nbsp; var def = new Deferred();
&amp;nbsp; var widget = registry.byId(id);
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp; if (widget || count === 0) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; def.resolve(widget);
&amp;nbsp;&amp;nbsp;&amp;nbsp; return def.promise;
&amp;nbsp; }
&amp;nbsp; 
&amp;nbsp; setTimeout(lang.hitch(this, function() {
&amp;nbsp;&amp;nbsp;&amp;nbsp; this._getWidgetWhenLoaded(id, wait, count - 1).then(function(widget) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; def.resolve(widget);
&amp;nbsp;&amp;nbsp;&amp;nbsp; });
&amp;nbsp; }), wait);
&amp;nbsp; 
&amp;nbsp; return def;
},&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;__getWidgetWhenLoaded(id, wait, count) will return a widget that is autoloaded as soon as it is available.&amp;nbsp; id is the widget id (e.g. WidgetManager.getInstance().appConfig.widgetOnScreen.widgets[4].id), wait is the milliseconds to wait between each attempt, and count is the number of times to try.&amp;nbsp; If wait is 100 and count is 10, it will try to get the widget every 100 milliseconds for a maximum of 1 second.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using these functions to retrieve and/or start the Attribute Table, Basemap Gallery, Coordinate, Geocoder, LayerList, and Scalebar widgets along with a couple of custom widgets I have written.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Larry&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 09:12:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-programmatically-open-a-widgetonscreen/m-p/796571#M4690</guid>
      <dc:creator>LarryStout</dc:creator>
      <dc:date>2021-12-12T09:12:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to programmatically open a widgetOnScreen widget</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-programmatically-open-a-widgetonscreen/m-p/796572#M4691</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The functions that Larry provided are great. Unfortunately, they didn't exactly work for me. I "think" (not sure), a lot depends on what kind of widget, panel, and group you are dealing with.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I posted a similar question here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/thread/119987"&gt;Web Appbuilder Communication Between Widgets&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And the function that I'm using, similar to one of Larry's, is here:&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.noblebuffalo.com/2015/02/get-on-the-event-bus/" title="http://www.noblebuffalo.com/2015/02/get-on-the-event-bus/"&gt;Get on the “Event Bus” | A.J. Morris&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After all that, my gut tells me that we need to get a handle to the HeaderController widget somehow, and use it's functions for showing the widget.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Feb 2015 18:21:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-programmatically-open-a-widgetonscreen/m-p/796572#M4691</guid>
      <dc:creator>deleted-user-Jie3eyjOl9XM</dc:creator>
      <dc:date>2015-02-06T18:21:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to programmatically open a widgetOnScreen widget</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-programmatically-open-a-widgetonscreen/m-p/796573#M4692</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;AJ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I remember correctly, to start an inPanel widget, you only need to start the panel.  See my _GetPanel function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;More details on exactly what you are trying to do and what is going wrong would be helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Larry&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Feb 2015 19:02:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-programmatically-open-a-widgetonscreen/m-p/796573#M4692</guid>
      <dc:creator>LarryStout</dc:creator>
      <dc:date>2015-02-06T19:02:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to programmatically open a widgetOnScreen widget</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-programmatically-open-a-widgetonscreen/m-p/796574#M4693</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have problem, i need to open widget from another widget by code&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Feb 2015 10:15:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-programmatically-open-a-widgetonscreen/m-p/796574#M4693</guid>
      <dc:creator>AsmaaMohamed</dc:creator>
      <dc:date>2015-02-10T10:15:27Z</dc:date>
    </item>
  </channel>
</rss>

