Multiple value search in findtask

1868
4
02-25-2016 10:15 PM
ADITYAKUMAR1
Occasional Contributor III

Hi All,

I need to search some data and display it into the Grid. I am using this example as a reference

Show find task results in a DataGrid | ArcGIS API for JavaScript . But here I am not able to search only one value at a time as mentioned in the example the word to be "Katz". But in my case I want to search with "Katz" and "Allen".

Any idea how to do it?

Thanks

Aditya Kumar

0 Kudos
4 Replies
RobertScheitlin__GISP
MVP Emeritus

Aditya,

   The FindTask is not designed to search for multiple values in a find. You can add the contains parameter to the FindParameters and you will get results for Allen whether the field begins with or ends with Allen though.

findParams.contains = true;

ADITYAKUMAR1
Occasional Contributor III

Hi Robert,

  Thanks for the reply.In my case I will be passing the unique key in order do the search so may be the above case may not work. Can you suggest me something which may be helpful if I need to search for example I pass the query as search cities with different pin code and I give 3 different pin code for search

Thanks

Aditya Kumar

0 Kudos
thejuskambi
Occasional Contributor III

You could use '&' or comma (,) or some special charater as delimiter and split the input string to array. Then loop through them and execute multiple findtasks. And then using promise/all combine all the results and use it to populate the grid.

RobertScheitlin__GISP
MVP Emeritus

Aditya,

   You are only searching one layer then I would reccomend using a QueryTask instead of a FindTask. In the Queries where property you can use the IN operator to allow for the user to input a comma separated  string of multiple values.