AnsweredAssumed Answered

How to add Feature Layer created programtically using feature Layer Defination to Search widget in WAB

Question asked by AVTSPositioning on Mar 20, 2017
Latest reply on Mar 21, 2017 by rscheitlin

I have created a feature layer given on https://developers.arcgis.com/javascript/3/jssamples/fl_featureCollection.html in custom widget.  I tried to bind the programmatically created Feature layer with ESRI search widget. Here is my code

UpdateSearch:function(){
    var widgets = this.appConfig.getConfigElementsByName('Search');
    
   var searchWidget =this.widgetManager.getWidgetById(widgets[0].id);
   var src =
                           [
                             {
                               featureLayer: featureLayer,
                               name:"myLayer",
                               searchFields: ["ObjectId"],
                               displayField: "Name",
                               exactMatch: false,
                               outFields: ["*"],                               
                               suggestionsEnabled: true,
                               
                           }/*,
                           {
                               locator: new Locator("//geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer"),
                               singleLineFieldName: "SingleLine",
                               outFields: ["Addr_type"],
                               name: "Adress"
                           }*/
                           ];  //new source
                    searchWidget.sources = src;   
                    searchWidget.addLayersFromMap=true;                    
                    console.log(searchWidget.sources);
                   

   }

 

 

The layer doesn't appear in search widget.

 

Thanks in advance.

Kumar

Outcomes