Change placeholder text for the Search widget in developer version of WAB?

4539
5
Jump to solution
09-15-2015 01:03 PM
MichelleD
New Contributor III

I have added a couple search sources to the Search widget in WAB.  The placeholder text for these shows as I have set them, but I want to replace the placeholder text for All of "Find address or place" to better reflect the searches I have set up.  I did find a thread on the API for JavaScript, but nothing on how to do it in WAB.

Thanks,

Michelle

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Esteemed Contributor

Michelle,

  Open the [install dir]\server\apps\[app#]\widgets\Search\Widget.js and find the startup function and add line 29 below (Don't forget to add the comma on line 28):

startup: function() {
        this.inherited(arguments);
        if (!(this.config && this.config.sources)) {
          this.config.sources = [];
        }

        LayerInfos.getInstance(this.map, this.map.itemInfo)
          .then(lang.hitch(this, function(layerInfosObj) {
            this.layerInfosObj = layerInfosObj;
            utils.setMap(this.map);
            utils.setLayerInfosObj(this.layerInfosObj);
            utils.setAppConfig(this.appConfig);
            when(utils.getConfigInfo(this.config)).then(lang.hitch(this, function(config) {
              if (!this.domNode) {
                return;
              }

              var searchSouces = this._convertConfig(config);
              this.searchDijit = new Search({
                activeSourceIndex: searchSouces.length === 1 ? 0 : 'all',
                autoSelect: false,
                enableButtonMode: false,
                enableLabel: false,
                enableInfoWindow: true,
                showInfoWindowOnSelect: true,
                map: this.map,
                sources: searchSouces,
                theme: 'arcgisSearch',
                allPlaceholder: 'My Placeholder'
              });
              html.place(this.searchDijit.domNode, this.searchNode);

View solution in original post

5 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Michelle,

  Open the [install dir]\server\apps\[app#]\widgets\Search\Widget.js and find the startup function and add line 29 below (Don't forget to add the comma on line 28):

startup: function() {
        this.inherited(arguments);
        if (!(this.config && this.config.sources)) {
          this.config.sources = [];
        }

        LayerInfos.getInstance(this.map, this.map.itemInfo)
          .then(lang.hitch(this, function(layerInfosObj) {
            this.layerInfosObj = layerInfosObj;
            utils.setMap(this.map);
            utils.setLayerInfosObj(this.layerInfosObj);
            utils.setAppConfig(this.appConfig);
            when(utils.getConfigInfo(this.config)).then(lang.hitch(this, function(config) {
              if (!this.domNode) {
                return;
              }

              var searchSouces = this._convertConfig(config);
              this.searchDijit = new Search({
                activeSourceIndex: searchSouces.length === 1 ? 0 : 'all',
                autoSelect: false,
                enableButtonMode: false,
                enableLabel: false,
                enableInfoWindow: true,
                showInfoWindowOnSelect: true,
                map: this.map,
                sources: searchSouces,
                theme: 'arcgisSearch',
                allPlaceholder: 'My Placeholder'
              });
              html.place(this.searchDijit.domNode, this.searchNode);
MichelleD
New Contributor III

Exactly what I needed, thank you so much!  I often find your replies to others helpful as well, Esri should put you on the payroll!

0 Kudos
ZeZhengLi
Occasional Contributor

Robert,

     It works fine by use `allPlaceholder`!

    

     Could you tell me where you find this property, I never found this property in doc of api.

Thanks.

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

ZeZheng Li,

    Matt Driscoll, mentioned in this thread Re: Discover the Search widget that it is currently undocumented but they were going to fix that.

TonyBedogne
New Contributor II

This is perfect!  works like a charm even still on 2.22

Thank you!

0 Kudos