Theme: Launchpad
WabDev 2.7
In addition to opening a particular widget from an existing widget (ScaleBar widget) when the app loads, I need to remove or disable another widget in the widgetpool. Remove it or disable it is fine, whichever is easiest.
var widgetsConfig = this.appConfig.widgetPool.widgets;
var widgetId;
for (var i in widgetsConfig) {
if (widgetsConfig[i].name == "My Widget Name") {
widgetId = widgetsConfig[i].id;
break;
}
}
var abc = WidgetManager.getInstance().getWidgetsByName("AnchorBarController")[0];
abc.setOpenedIds([widgetId]); //this opens the desired widget
// I need to remove it from the Controller or just deactivate it somehow.
abc.removeFromController([widgetId]); //or some such thing
Solved! Go to Solution.
James,
Here is what you need for that:
var widgetsConfig = this.appConfig.widgetPool.widgets;
var widgetId;
for(var i in widgetsConfig) {
if(widgetsConfig[i].name == "InfoSummary") {
widgetId = widgetsConfig[i].id;
break;
}
}
setTimeout(function() {
var abc = WidgetManager.getInstance().getWidgetsByName("AnchorBarController")[0]; //abc is getting set to undefined
// debugger;
abc.setOpenedIds([widgetId]); //this opens the desired widget
//Now remove the legend anchorbar controller item
var item, itemIndx;
abc.iconList.some(function(icon, index){
if(icon.config.name === 'Legend') {
item = icon;
itemIndx = index;
return true;
}
});
abc.iconGroupNode.removeChild(item.domNode);
abc.iconList.splice(itemIndx, 1);
abc.allConfigs.some(function(config, index){
if(config.name === 'Legend'){
abc.allConfigs.splice(index, 1);
return true;
}
});
abc.resize();
}, 1000);
James,
Here is what you need for that:
var widgetsConfig = this.appConfig.widgetPool.widgets;
var widgetId;
for(var i in widgetsConfig) {
if(widgetsConfig[i].name == "InfoSummary") {
widgetId = widgetsConfig[i].id;
break;
}
}
setTimeout(function() {
var abc = WidgetManager.getInstance().getWidgetsByName("AnchorBarController")[0]; //abc is getting set to undefined
// debugger;
abc.setOpenedIds([widgetId]); //this opens the desired widget
//Now remove the legend anchorbar controller item
var item, itemIndx;
abc.iconList.some(function(icon, index){
if(icon.config.name === 'Legend') {
item = icon;
itemIndx = index;
return true;
}
});
abc.iconGroupNode.removeChild(item.domNode);
abc.iconList.splice(itemIndx, 1);
abc.allConfigs.some(function(config, index){
if(config.name === 'Legend'){
abc.allConfigs.splice(index, 1);
return true;
}
});
abc.resize();
}, 1000);
You're an amazing resource.
I was looking for a specific function in the WidgetManager to remove/destroy the widget, will have to take a bit to digest the solution you've provided!
Much appreciated.