Close eSearch widget programmatically

4338
7
Jump to solution
05-07-2015 10:30 AM
RyanStrain
New Contributor III

Does anyone have any idea how to close the eSearch widget programmatically after it has finished loading on startup? I want it to "openAtStart" to enable me to use the "esearch" and "slayer" URL parameters from a different application, although I don't want it to remain open for my users. Hopefully that makes some sense?

I've been playing around in the WidgetManager.js trying widget.closeWidget() and widget.destroy() and _removeWidget('_6') to no avail. Maybe I'm not placing these in the right place?

Thanks!

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Ryan,

  OK here is how to close a widget.

you need this require:

'jimu/PanelManager'

PanelManager.getInstance().closePanel(this.id + '_panel');

Now where you place this in the eSearch widgets code is a whole other story. You need to do this after the widget is done searching (but not when any search is done...).

I have attached a version that does this only for url searches (I did not test this much).

View solution in original post

7 Replies
RobertScheitlin__GISP
MVP Emeritus

Ryan,

   So you want it to use the URL search and then when it has completed the initial search to close? So what good with the search be? Are you only wanting the results to remain displayed in the Attribute Table Widget?

0 Kudos
RyanStrain
New Contributor III

Exactly. It's not professional. I was just looking for a quick way to zoom to a feature, highlight it, and have the attributes exposed using only url parameters. Your eSearch widget provides that URL usage. It may not be the solution, I just wanted to see how it would look, and I'm frustrated that I can't simply get the widget to programmatically close. Thanks.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Ryan,

  OK here is how to close a widget.

you need this require:

'jimu/PanelManager'

PanelManager.getInstance().closePanel(this.id + '_panel');

Now where you place this in the eSearch widgets code is a whole other story. You need to do this after the widget is done searching (but not when any search is done...).

I have attached a version that does this only for url searches (I did not test this much).

RyanStrain
New Contributor III

Thanks Robert. My request was confusing, and probably only specific to my needs. I was able to use the PanelManager.js to close the eSearch widget before it displays. That way the URL parameters are available for an external application to open zoomed to a highlighted feature with the table displayed.

   

Also, users navigating directly to the site won't notice the widget enabling.

   

0 Kudos
soniamonga
New Contributor II

strainryan

Can you please share the closePanel code if possible? I am trying to replicate the same thing but I am unable to make it work.

Thanks,

Sonia

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Sonia,

   There is a close url parameter available for the eSearch:

Web AppBuilder for ArcGIS | Help - Enhanced Search widget | url parameters 

You can optionally add an ampersand and then the close parameter and equals sign followed by true. The close parameter will close the eSearch widget once the URL search is done executing. Here is an example: &close=true.

This is useful if you want the search results added to the map and/or Attribute Table Widget and do not need the eSearch widget visible after that. The widget must be set to "open at start" in order for the widget to execute the search when the app starts.

To set the widget to "open at start" just click the lower left corner of the widget icon as indicated below.

soniamonga
New Contributor II

Thank you Robert! Appreciate your prompt reply.