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!
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
});
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?
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.
Maybe you can test it for me, I still get results from ESRI World geocoder and "Parcel address search"
Try "2235 1st ave ne"
Leo,
Yep this looks like a bug.
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
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.