I am looking for some example of setting the default search service to all(feature layer and esri geocoding). but I also care about the order of the results returned.
I suspect this is accomplished using the activeSource parameter of the search widget. But have not been able to find an example of this implemented.
I have tried implementing like this..
var searchWidget = new Search({ container: "searchDiv", view: view, allPlaceholder: "Places or Tyler Communities", activeSource: 0, sources: [{ featureLayer: { url: "https://services5.arcgis.com/6gTxIFMxZdWxCrVQ/arcgis/rest/services/...", popupTemplate: { // autocasts as new PopupTemplate() title: "{customer} is Tyler Connected Community!", overwriteActions: true } }, activeSourceIndex: 1, searchFields: ["customer", "city", "state"], displayField: "customer", exactMatch: false, outFields: ["*"], name: "Tyler Communities", placeholder: "example: city of birmingham", zoomScale: 500000 }]});
and also like this...
searchWidget.activeSource = 0;
But both return this error...
dojo.js:340 Uncaught TypeError: [accessor] cannot assign to read-only property 'activeSource' of esri.widgets.Search.SearchViewModel
Any help is greatly appreciated.
Noah,
As you can see from your error the activeSource property is readonly
activeSourceFeatureLayer|Locatorreadonly
what you need to use is activeSourceIndex which will let you set the number/index of the source.
Hi Robert. Thank you for the response. Good to know I was getting close. I still have not seen activeSourceIndex implemented. Can you provide an example?
Noah,
I have not seen any example of it being implemented either. It is a simple property that you set either in the constructor or after creating the widget instance, so nothing special to show in code.