Close the widget programmatically
The custom widget can be closed programmatically so that users don't need to click the close button.
For in-panel widgets, do the following:
define([ 'jimu/PanelManager'], function('PanelManager'){
afterSomething: function(){
//Get widgetid by using this id
PanelManager.getInstance().closePanel(widgetid + ‘_panel’);
}
});
For off-panel widgets, do the following:
WidgetManager. getInstance().closeWidget(widgetId)
The closeWidget function changes the widget state and calls the onClose method. You can override the onClose method to hide or destroy the widget.