How to open a widget from another widget. I have a scenario like, After getting the resulted location in map(Search widget) it should open the Identify widget. Which of the files need to be edited in both widgets.
Thanks in advance.
Solved! Go to Solution.
Ibrahim,
So it turns out that the code to open the draw widget in the TabTheme should be:
_openDrawWidget: function() { var drawWidget, sbc; var widgetCfg = this._getWidgetConfig('Draw'); if (widgetCfg) { sbc = WidgetManager.getInstance().getWidgetsByName("SidebarController")[0]; sbc._resizeToMax(); sbc.setOpenedIds([widgetCfg.id]); } }
d ibrahim,
The code necessary can depend on the theme you are using. Which theme are you using?
WidgetManager class—Web AppBuilder for ArcGIS (Developer Edition) | ArcGIS for Developers
Hi Robert,
I'm using Tab theme for this application.
d ibrahim,
So the first link I posted is the one you want to look at then as that poster was working with the TabTheme as well.
Hi Robert,
I'm implementing the code which is in 1st link, Could you define the _getWidgetConfig('Print') function.
Thanks for suggesting me...
Hi Robert,
Even I am looking for that _getWidgetConfig('Print') function.
could u please share _getWidgetConfig('Print') function code and if any userdefined functions inside the _getWidgetConfig('Print') please attach the code for that functions also.
d ibrahim,
Looking at that thread again I realize that it is dealing with the LaunchPad theme and not the Tab theme so you need to use:
Add these Require statements to your code:
'jimu/WidgetManager', 'jimu/PanelManager WidgetManager, PanelManager
Then these new functions:
_getWidgetConfig: function(widgetName){
var widgetCnfg = null;
array.some(WidgetManager.getInstance().appConfig.widgetPool.widgets, function(aWidget) {
if(aWidget.name == widgetName) {
widgetCnfg = aWidget;
return true;
}
return false;
});
if(!widgetCnfg){
/*Check OnScreen widgets if not found in widgetPool*/
array.some(WidgetManager.getInstance().appConfig.widgetOnScreen.widgets, function(aWidget) {
if(aWidget.name == widgetName) {
widgetCnfg = aWidget;
return true;
}
return false;
});
}
return widgetCnfg;
},
_openPrintWidget: function() {
var printWidget, sbc;
var widgetCfg = this._getWidgetConfig('Print');
if (widgetCfg) {
sbc = WidgetManager.getInstance().getWidgetsByName("SidebarController")[0];
printWidget = WidgetManager.getInstance().getWidgetByLabel(widgetCfg.label);
if (printWidget) {
sbc.setOpenedIds([widgetCfg.id]);
sbc._resizeToMax();
WidgetManager.getInstance().openWidget(printWidget);
PanelManager.getInstance().showPanel(printWidget);
} else {
sbc.setOpenedIds([widgetCfg.id]);
sbc._resizeToMax();
setTimeout(function() {
printWidget = WidgetManager.getInstance().getWidgetById(widgetCfg.id);
WidgetManager.getInstance().openWidget(printWidget);
PanelManager.getInstance().showPanel(printWidget);
}, 3000);
}
}
}
Then call the _openPrintWidget function
this._openPrintWidget();
Hi Robert, I tried this code in the tab theme and this work correctly , but I tried in a "SidebarTheme7" and it doesn´t work correctly. The "sbc" is undefined. I don´t understand this, because the widget that contains the widgets in my "SidebarTheme7" is "SidebarController". Need I a other function for my theme?
I attached my theme in this link : https://drive.google.com/open?id=1_Zw0huZZrP9y5UZA_brFb4KAbgQHH6wv
Thanks for all!
Angel,
So you have:
sbc = WidgetManager.getInstance().getWidgetsByName("SidebarTheme7")[0];
in your code?
No, I have this in my code :
sbc = WidgetManager.getInstance().getWidgetsByName("SidebarController")[0];
Thanks!