Turning off eSearch Widget when opening another widget

367
12
Jump to solution
10-17-2018 06:00 AM
RichBell
Occasional Contributor

Robert,

I have the eSearch widget configured to open at the start. Now I need to automatically close the widget when I open another widget called Sewer Capacity Calculator. What piece of code is needed and where would it go?

Also, at the same time I would like to turn off the Ortho image as the widget is opened, same thing how do I do this?

Please see attached image.

Thank You!

Rich

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Esteemed Contributor

Rich,

  Sounds like you have messed up your widgets require array. Can you Post your define section and the following function list?

View solution in original post

0 Kudos
12 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Rich,

You would need to add this to the sewer widget onOpen function

//require
'jimu/PanelManager',  
PanelManager,  

//code
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  ‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

For turning a layer on or off see this thread:

https://community.esri.com/thread/183992-turn-on-layers-on-widget-start 

0 Kudos
RichBell
Occasional Contributor

The eSearch widget is in a WidgetPool and is not a WidgetOnSreen.

Ok, I tried fooling with the code but either way I get an "setState" error.

This is my attempt putting in the code you gave me.

onOpen: function () {
//BELL Add to close other widgets at start up
var pm = PanelManager.getInstance();
//pm.closePanel(this.appConfig.widgetOnScreen.widgets[4]);

pm.closePanel(this.appConfig.widgetPool.widgets[1]);
//close the 5th widget in the config.json inside the widgetOnScreen object
//or
// pm.closePanel(pm.activePanel);//close the active panel
  //End Bell Add

This is the error?

init.js:114 TypeError: panel.setState is not a function
    at Object.<anonymous> (PanelManager.js?wab_dv=2.9:197)
    at init.js:63
    at k (init.js:107)
    at b.extend.then.then.b.then (init.js:110)
    at Object.closePanel (PanelManager.js?wab_dv=2.9:192)
    at Object.onOpen (Widget.js?wab_dv=2.9:964)
    at Object.openWidget (WidgetManager.js?wab_dv=2.9:569)
    at Object._postWidgetStartup (WidgetManager.js?wab_dv=2.9:1130)
    at Object.<anonymous> (init.js:63)
    at Object.c [as startup] (init.js:119) "TypeError: panel.setState is not a function
    at Object.<anonymous> (http://localhost:63342/MAHGIS_2.9/jimu.js/PanelManager.js?wab_dv=2.9:197:15)
    at https://js.arcgis.com/3.25/init.js:63:337
    at k (https://js.arcgis.com/3.25/init.js:107:277)
    at b.extend.then.then.b.then (https://js.arcgis.com/3.25/init.js:110:152)
    at Object.closePanel (http://localhost:63342/MAHGIS_2.9/jimu.js/PanelManager.js?wab_dv=2.9:192:50)
    at Object.onOpen (http://localhost:63342/MAHGIS_2.9/widgets/CapacityCalculation/Widget.js?wab_dv=2.9:964:20)
    at Object.openWidget (http://localhost:63342/MAHGIS_2.9/jimu.js/WidgetManager.js?wab_dv=2.9:569:18)
    at Object._postWidgetStartup (http://localhost:63342/MAHGIS_2.9/jimu.js/WidgetManager.js?wab_dv=2.9:1130:12)
    at Object.<anonymous> (https://js.arcgis.com/3.25/init.js:63:15)
    at Object.c [as startup] (https://js.arcgis.com/3.25/init.js:119:235)
    ----------------------------------------
    rejected at a (https://js.arcgis.com/3.25/init.js:108:174)
    at k (https://js.arcgis.com/3.25/init.js:107:436)
    at b.extend.then.then.b.then (https://js.arcgis.com/3.25/init.js:110:152)
    at Object.closePanel (http://localhost:63342/MAHGIS_2.9/jimu.js/PanelManager.js?wab_dv=2.9:192:50)
    at Object.onOpen (http://localhost:63342/MAHGIS_2.9/widgets/CapacityCalculation/Widget.js?wab_dv=2.9:964:20)
    at Object.openWidget (http://localhost:63342/MAHGIS_2.9/jimu.js/WidgetManager.js?wab_dv=2.9:569:18)
    at Object._postWidgetStartup (http://localhost:63342/MAHGIS_2.9/jimu.js/WidgetManager.js?wab_dv=2.9:1130:12)
    at Object.<anonymous> (https://js.arcgis.com/3.25/init.js:63:15)
    at Object.c [as startup] (https://js.arcgis.com/3.25/init.js:119:235)
    at Object.<anonymous> (http://localhost:63342/MAHGIS_2.9/jimu.js/BaseWidgetPanel.js?wab_dv=2.9:78:18)
    ----------------------------------------
Error
    at b.extend.then.then.b.then (https://js.arcgis.com/3.25/init.js:110:97)
    at Object.closePanel (http://localhost:63342/MAHGIS_2.9/jimu.js/PanelManager.js?wab_dv=2.9:192:50)
    at Object.onOpen (http://localhost:63342/MAHGIS_2.9/widgets/CapacityCalculation/Widget.js?wab_dv=2.9:964:20)
    at Object.openWidget (http://localhost:63342/MAHGIS_2.9/jimu.js/WidgetManager.js?wab_dv=2.9:569:18)
    at Object._postWidgetStartup (http://localhost:63342/MAHGIS_2.9/jimu.js/WidgetManager.js?wab_dv=2.9:1130:12)
    at Object.<anonymous> (https://js.arcgis.com/3.25/init.js:63:15)
    at Object.c [as startup] (https://js.arcgis.com/3.25/init.js:119:235)
    at Object.<anonymous> (http://localhost:63342/MAHGIS_2.9/jimu.js/BaseWidgetPanel.js?wab_dv=2.9:78:18)
    at https://js.arcgis.com/3.25/init.js:63:337
    at k (https://js.arcgis.com/3.25/init.js:107:277)"

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Rich,

   Then you need to provide more info. What theme are you using and where in that theme is the eSearch widget added?

0 Kudos
RichBell
Occasional Contributor

I'm using a Foldable Panel Theme.

This is the config...

"widgetPool": {
"panel": {
"uri": "themes/FoldableTheme/panels/FoldablePanel/Panel",
"position": {
"top": 5,
"left": 15,
"bottom": 5,
"zIndex": 5,
"relativeTo": "map"
}
},
"widgets":[
{
"name":"eSearch",
"label": "Sanitary Search Tools",
"uri": "widgets/eSearchSanitary/Widget",
"config": "configs/eSearch/config_eSanitary.json",
"icon": "configs\\eSearch\\i_searchsan.png",
"id": "widgets_eSearchSanitary_Widget_500",
"openAtStart": true,
"position": {
"top": 70,
"left": 4,
"height": 420,
"width": 360,
"relativeTo": "map"
}, "index": 1,
"version": "2.7"
},

Where does the "Require" for the PanelManager go?

That may be the issue???

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

with the rest of the require entries at the top of the widget.js.

0 Kudos
RichBell
Occasional Contributor

Oh, then yes they are in the correct place. but still no luck

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Rich,

  Here is the correct code for the onOpen function for your setup then:

        var pm = PanelManager.getInstance();
        pm.closePanel(this.appConfig.widgetPool.widgets[1].id + '_panel');

Assuming that the eSearch is actually your second widget in the header controller widget. From your code paste above it looks like it is the first in the header controller and that would mean.

        var pm = PanelManager.getInstance();
        pm.closePanel(this.appConfig.widgetPool.widgets[0].id + '_panel');‍‍
0 Kudos
RichBell
Occasional Contributor

Still no luck turning of the eSearch Widget?

I'm missing something???

Turning off the Imagery does work...Thank You!

Code

error

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Rich,

  Sounds like you have messed up your widgets require array. Can you Post your define section and the following function list?

0 Kudos