hide a widget programmatically..

3368
3
Jump to solution
12-16-2015 12:09 AM
NatashaManzuiga
Occasional Contributor

Hi all,
Is it possible to hide a widget programmatically?
I want to do this without close a widget.

Thanks,

Naty

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Naty,

  It depends on if it is an onscreen widget or a widget in the widgetpool.

Here is the code that works for onscreen widget:

Require

'jimu/PanelManager',
PanelManager,

var pm = PanelManager.getInstance();  
pm.closePanel(this.appConfig.widgetOnScreen.widgets[4]);//close the 5th widget in the config.json inside the widgetOnScreen object
//or
pm.closePanel(pm.activePanel);//close the active panel

View solution in original post

3 Replies
RobertScheitlin__GISP
MVP Emeritus

Naty,

  It depends on if it is an onscreen widget or a widget in the widgetpool.

Here is the code that works for onscreen widget:

Require

'jimu/PanelManager',
PanelManager,

var pm = PanelManager.getInstance();  
pm.closePanel(this.appConfig.widgetOnScreen.widgets[4]);//close the 5th widget in the config.json inside the widgetOnScreen object
//or
pm.closePanel(pm.activePanel);//close the active panel

ChristopherSchreiber
Occasional Contributor II

rscheitlin 

I have been trying to close a widget when my custom widget is opened. I have used your solution above, but because the widget that I am trying to close resided in the widget pool, I have changed 

pm.closePanel(this.appConfig.widgetOnScreen.widgets[4])

 

to

pm.closePanel(this.appConfig.widgetPool.widgets[1]);

I keep getting an error that reads:

TypeError: panel.setState is not a function

The widget is an "In-Panel" widget.

Would you have any idea as to why I am getting this error?

Thank You!

Chris

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Chris,

   What theme are you using? A screen shot would really help.

0 Kudos