Select to view content in your preferred language

Search Widget, remove "all" setting

5285
7
05-19-2016 10:04 AM
LeoLadefian5
Frequent Contributor

I'm trying to remove the "all" feature from the out of the box search widget in WAB 2.0.  Every time a search is done with the "all" setting it bogs down our server to a crawl.  Any ideas?  Thanks!

Tags (1)
0 Kudos
7 Replies
RobertScheitlin__GISP
MVP Emeritus

Leo,

Add enableSearchingAll: false to the Widget.js startup function:

this.searchDijit = new Search({

                activeSourceIndex: searchSouces.length === 1 ? 0 : 'all',

                allPlaceholder: jimuUtils.stripHTML(esriLang.isDefined(this.config.allPlaceholder) ?

                  this.config.allPlaceholder : ""),

                autoSelect: true,

                enableButtonMode: false,

                enableLabel: false,

                enableInfoWindow: true,

                enableHighlight: esriLang.isDefined(this.config.showInfoWindowOnSelect) ?

                  !!this.config.showInfoWindowOnSelect : true,

                showInfoWindowOnSelect: esriLang.isDefined(this.config.showInfoWindowOnSelect) ?

                  !!this.config.showInfoWindowOnSelect : true,

                map: this.map,

                sources: searchSouces,

                theme: 'arcgisSearch',

               enableSearchingAll: false

              });

LeoLadefian5
Frequent Contributor

Thanks, that removed the all search, however I'm still able to search all the layers through the default box, any way to disable that and replace it with text instructions?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Leo,

  With the enableSearchingAll set to false the search widget will be searching the first source in the list. So if you have a normal setup then the "esri world geocoder" will be searched and not all items in the sources as before.

LeoLadefian5
Frequent Contributor

Maybe you can test it for me, I still get results from ESRI World geocoder and "Parcel address search"

Try "2235 1st ave ne"

Property Information Viewer

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Leo,

  Yep this looks like a bug.

DavidOlson1
New Contributor

I managed this by changing the active source index to 0.

Since if you have multiple sources the default constructor will always resolve to 'all'

I also added in what Robert said to remove the all option.

this.searchDijit = new Search({
//activeSourceIndex: searchSouces.length === 1 ? 0 : 'all', CHANGED THIS LINE TO BELOW
activeSourceIndex: 0,
allPlaceholder: jimuUtils.stripHTML(esriLang.isDefined(this.config.allPlaceholder) ?
this.config.allPlaceholder : ""),
autoSelect: true,
enableButtonMode: false,
enableLabel: false,
enableInfoWindow: true,
enableHighlight: esriLang.isDefined(this.config.showInfoWindowOnSelect) ?
!!this.config.showInfoWindowOnSelect : true,
showInfoWindowOnSelect: esriLang.isDefined(this.config.showInfoWindowOnSelect) ?
!!this.config.showInfoWindowOnSelect : true,
map: this.map,
sources: searchSouces,
theme: 'arcgisSearch',
enableSearchingAll: false

chrisjones2
New Contributor

Works great in WAB. Are you able to add this to arcgis portal as a custom widget? I'm getting errors trying to do that.

0 Kudos