Hello fellows,
I am trying to open LDockable panel in my Jewelry box theme,I want to open on button click function from my other widget. I am using WAB Dev Edt 2.7. By default my LDockable panel is closed.Here is the function, which i tried so far.
_showFoldablePanel: function (){
var pm =PanelManager.getInstance();
pm.openPanel(this.appConfig.widgetPool.panel[0]);
},
Thanks,
Irfan Afsar
Solved! Go to Solution.
Irfan,
So here is what you will need to add to your widget that is attempting to open the LDockable Panel.
1. Add these defines
define([
...
'jimu/WidgetManager',
'jimu/PanelManager',
'dojo/_base/array'
...
WidgetManager, PanelManager, array
2. Add this to your button event listener. (the comment in line 4 is !!!IMPORTANT!!!)
this.wManager = WidgetManager.getInstance();
this.pManager = PanelManager.getInstance();
var widgetCfg = this._getWidgetConfig('Print');
///The above 'Print' need to be swapped for your widgetsname that is in the LDockable panel
if(widgetCfg) {
var tWidget = this.wManager.getWidgetByLabel(widgetCfg.label);
if(tWidget) {
this.wManager.openWidget(tWidget);
PanelManager.getInstance().maximizePanel(tWidget.getPanel());
} else {
this.wManager.loadWidget(widgetCfg).then(lang.hitch(this, function(widget) {
if(widget) {
this.wManager.openWidget(widget);
PanelManager.getInstance().maximizePanel(widget.getPanel());
}
}));
}
}
3. Add this new helper function to your widget that is opening the LDockable Panel:
_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;
});
}
if(!widgetCnfg) {
/*Check OnScreen groups widgets if not found in OnScreen widgets*/
array.map(WidgetManager.getInstance().appConfig.widgetOnScreen.groups, function(aGroup) {
array.some(aGroup.widgets, function(aWidget) {
if(aWidget.name == widgetName) {
widgetCnfg = aWidget;
return true;
}
return false;
});
});
}
return widgetCnfg;
},
Irfan,
If you look in my popup panel widget I have code in there to open the LDockable panel from code.
Irfan,
So here is what you will need to add to your widget that is attempting to open the LDockable Panel.
1. Add these defines
define([
...
'jimu/WidgetManager',
'jimu/PanelManager',
'dojo/_base/array'
...
WidgetManager, PanelManager, array
2. Add this to your button event listener. (the comment in line 4 is !!!IMPORTANT!!!)
this.wManager = WidgetManager.getInstance();
this.pManager = PanelManager.getInstance();
var widgetCfg = this._getWidgetConfig('Print');
///The above 'Print' need to be swapped for your widgetsname that is in the LDockable panel
if(widgetCfg) {
var tWidget = this.wManager.getWidgetByLabel(widgetCfg.label);
if(tWidget) {
this.wManager.openWidget(tWidget);
PanelManager.getInstance().maximizePanel(tWidget.getPanel());
} else {
this.wManager.loadWidget(widgetCfg).then(lang.hitch(this, function(widget) {
if(widget) {
this.wManager.openWidget(widget);
PanelManager.getInstance().maximizePanel(widget.getPanel());
}
}));
}
}
3. Add this new helper function to your widget that is opening the LDockable Panel:
_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;
});
}
if(!widgetCnfg) {
/*Check OnScreen groups widgets if not found in OnScreen widgets*/
array.map(WidgetManager.getInstance().appConfig.widgetOnScreen.groups, function(aGroup) {
array.some(aGroup.widgets, function(aWidget) {
if(aWidget.name == widgetName) {
widgetCnfg = aWidget;
return true;
}
return false;
});
});
}
return widgetCnfg;
},
Robert,
Great! It is working perfectly. Thanks again for your help!
Irfan Afsar