Search Widget Source

294
1
10-22-2019 12:24 AM
SaiAnandPeketi
New Contributor II

Hi All,

I'm working with Search Widget. In that we can set the multiple search source by passing in the source value. But can we get the multiple value inside a single feature class.

For Example, I have a type of "Xyz", "abc", and "pqs". Now, I want to search and people will select the dropdown value of "xyz" and the featurelayer will show only type of "xyz" in suggestion template and need to search. If anyone, did like this can you please share me some snippets code.

Like this example "Search multiple sources | ArcGIS API for JavaScript 3.30" Adding multiple sources with different feature layer but if it's a single feature class then how we can achieve it. Like can we apply any query field in the source to restrict only show the particular type?

Thanks,

Sai Anand Peketi

1 Reply
imritanshu
New Contributor III

Hi Andy,

As I understood you want to display dropdown based on type and filter results accordingly in the search widget.

You can achieve it by setting definition expression in the feature layer for each type and also add multiple sources for each type.

sources.push({
featureLayer: new FeatureLayer("https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/US_Senators/FeatureServer/0",{
definitionExpression:"name in ('Akaka, Daniel K.','Alexander, Lamar')"
}),
searchFields: ["Name"],
displayField: "Name",
exactMatch: false,
name: "Senator",
outFields: ["*"],
placeholder: "Senator name",
maxResults: 6,
maxSuggestions: 6,

//Create an InfoTemplate

infoTemplate: new InfoTemplate("Senator information",
"Name: ${Name}</br>State: ${State}</br>Party Affiliation: ${Party}</br>Phone No: ${Phone_Number}<br><a href=${Web_Page} target=_blank ;'>Website</a>"
)

Regards, 

#itsMeRhitz

0 Kudos