Search Widget, remove "all" setting

4107
7
05-19-2016 10:04 AM
Highlighted
Occasional Contributor II

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)
Reply
0 Kudos
7 Replies
Highlighted
MVP Esteemed Contributor

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

              });

Highlighted
Occasional Contributor II

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?

Reply
0 Kudos
Highlighted
MVP Esteemed Contributor

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.

Highlighted
Occasional Contributor II

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

Reply
0 Kudos
Highlighted
MVP Esteemed Contributor

Leo,

  Yep this looks like a bug.

Highlighted
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

Highlighted
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.

Reply
0 Kudos