How to set showSources=false in Search widget?

3441
6
Jump to solution
07-15-2015 10:27 PM
philippenn
Occasional Contributor

The search widget has a class, not a boolean property, for setting whether to show sources or not. I have a search widget with multiple sources.

I was assuming that the following would make "ESRI World Geocoder" entry name disappear from the dropdown when I start to type into the searchbox. What am I doing wrong?

.arcgisSearch .showSources {
     visibility: hidden;

showSources     Class indicating whether to display sources.

thanks

Phil

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Philip,

  OK, I think I understand now. Add this css (important part is line 5):

.arcgisSearch .searchMenu .menuHeader {
    padding: 6px 12px;
    background: #4C4C4C none repeat scroll 0% 0%;
    color: #FFF;
    display: none;
}

View solution in original post

6 Replies
RobertScheitlin__GISP
MVP Emeritus

Phillip,

  I think you are looking for the enableSourcesMenu property:

      var s = new Search({
        enableButtonMode: true, //this enables the search widget to display as a single button
        enableLabel: false,
        enableInfoWindow: true,
        showInfoWindowOnSelect: false,
        enableSourcesMenu: false,
        map: map
      }, "search");
philippenn
Occasional Contributor

I believe enableSourcesMenu may be what I want, but it doesn't seem to do anything for me.

To restate what I'm after. When I type into the search widget, I want to see suggestions in the dropdown as I type but I don't want to see the suggestion header.

So in this sample ( ArcGIS API for JavaScript Sandbox ) I don't want to see the "ESRI World Geocoder" and "Congressional Districts" titles. I do want their suggestions, just not the header/title.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Philip,

  OK, I think I understand now. Add this css (important part is line 5):

.arcgisSearch .searchMenu .menuHeader {
    padding: 6px 12px;
    background: #4C4C4C none repeat scroll 0% 0%;
    color: #FFF;
    display: none;
}
philippenn
Occasional Contributor

Bingo! Thanks

0 Kudos
KellyHutchins
Esri Frequent Contributor

Do you want to keep the menu but not have the Esri World Geocoder be one of the search sources? If so you can do this by defining sources and passing in those sources to the Search constructor.

         var sources = [];
         sources.push({
            featureLayer: new FeatureLayer("http://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/US_Senators/FeatureServer/0"),
            searchFields: ["Name"],
            displayField: "Name",
            exactMatch: false,
            name: "Senator",
            outFields: ["*"],
            placeholder: "Senator name",
            enableSuggestions: true
         });




         var s = new Search({
            sources: sources, 
            map: map
         }, "search");


         s.startup();
YueWu1
by Esri Regular Contributor
Esri Regular Contributor

Hi Philip,

Here is a search sample that you can take a look to compare your code:

Search multiple sources | ArcGIS API for JavaScrip