Can a selection (via ESRI WAB Search widget) remain visible when popup window is closed?

1539
7
Jump to solution
07-19-2016 06:13 AM
AdamGebhart
Occasional Contributor III

I have an AGOL popup window configured for my parcels layer that opens with the result(s) from the ESRI Search widget in my Web AppBuilder Developer 2.0 application.  When I close the popup I also lose the search result list in the Search widget itself, and I lose the selected item/symbology in my map.  Is there a way to close the popup but not lose the list and/or the map symbology/selected feature?

If it's of any significance, I also used Tyler Dunn's suggestion in this thread to make the popup window moveable.

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Esteemed Contributor

Adam,

  In the Search widgets Widget.js file you will find this block of code that clears the selected feature when the popup is closed:

comment out line 6:

this.own(
                on(this.map.infoWindow, 'show,hide', lang.hitch(this, function() {
                  if (this.searchDijit &&
                    this.map.infoWindow.getSelectedFeature() ===
                    this.searchDijit.highlightGraphic) {
                    //this.searchDijit.clearGraphics();
                    query('li', this.searchResultsNode).removeClass('result-item-selected');
                  }
                }))
              );

and this block is what hides the result list (line 4):

this.own(
                on(window.document, 'click', lang.hitch(this, function(e) {
                  if (!html.isDescendant(e.target, this.searchResultsNode)) {
                    this._hideResultMenu();
                    this._resetSelectorPosition('.show-all-results');
                  }
                }))
              );

I have not tested the effects of removing these.

View solution in original post

7 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Adam,

  In the Search widgets Widget.js file you will find this block of code that clears the selected feature when the popup is closed:

comment out line 6:

this.own(
                on(this.map.infoWindow, 'show,hide', lang.hitch(this, function() {
                  if (this.searchDijit &&
                    this.map.infoWindow.getSelectedFeature() ===
                    this.searchDijit.highlightGraphic) {
                    //this.searchDijit.clearGraphics();
                    query('li', this.searchResultsNode).removeClass('result-item-selected');
                  }
                }))
              );

and this block is what hides the result list (line 4):

this.own(
                on(window.document, 'click', lang.hitch(this, function(e) {
                  if (!html.isDescendant(e.target, this.searchResultsNode)) {
                    this._hideResultMenu();
                    this._resetSelectorPosition('.show-all-results');
                  }
                }))
              );

I have not tested the effects of removing these.

AdamGebhart
Occasional Contributor III

As always, thank you Robert.  This is exactly what our users have asked for.

I've commented out both lines you mentioned and we've had some of our users test it in Firefox, Chrome, Edge and IE.  So far, everything appears to be working properly, or we haven't noticed any side effects yet.  I'll let you know if we catch anything and will mark the question as answered if we don't see any issues.

Again, thank you very much.

JasonBerry
New Contributor II

I'm trying re-create this action allowing the selected highlight symbology to remain after the pop up is closed in the most recent version of web appbuilder (2.23).  The code has been changed to the point that Robert's solution is no longer valid.  For example, there is not a 'show, hide' action in the current Widget.js file.  I did have it functioning in an older version of web appbuilder (2.4).

Any insight on where this action can now be made? And on a similar topic, how can this symbolgy also remain when typical pop up is closed that was not executed from the Search widget?

Thanks.

0 Kudos
JoelEdgar
New Contributor II

In addition to this request, is it also possible to hide the popup attribute window so that it does not show when a search is performed. I don't want to disable the popup completely, I just don't want it to show when the search widget selects and zooms to the feature.

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Joel,

  Sure in the Search widgets settings page just un check "Show pop-up for the found feature or location"

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Adam,

Don't forget to mark this question as answered by clicking on the "Correct Answer" link on the reply that answered your question.

0 Kudos
AdamGebhart
Occasional Contributor III

Done.  Sorry about missing that.

0 Kudos