Search Widget

744
2
05-31-2017 06:12 AM
HeikeFriedrichs
New Contributor II

Hi,

we use the search widget for a search in a custom feature layer.
This works fine if we have an ID field for the layer and can find the result in one single field.

Now we want the users to enter TWO search terms seperated by a column delimiter and search for one term in one field and for the other in another field.
I was hoping to achieve this by altering the query with the searchQueryParams option, but no luck so far.

It it possible to overwrite the where-part of the underlying query with that option?

Has anybody got an example for how to do that?
Is it possible to hook up an entirely new query with the search widget?

Any ideas?

We use JS API 3.20, but I guess this is version independent.

0 Kudos
2 Replies
MeleKoneya
Occasional Contributor III

Any luck with resolving this?    I would like to do the same thing and change the where query that is used by the widget.

Thanks,

Mele

0 Kudos
HeikeFriedrichs
New Contributor II

Hi,

sorry for the delay. I had given up hope that anybody would answer.

We found two soulutions (both work):

- we added a (redundant) field in the table with the two fields concatenated and use that combined field in the search widget instead

- we added two dijit Input fields and a search button in the map as a completely separate search option, onClick on the button starts a query that gives you full flexibility

If field #1 (schiebersearch1) contains data, its content gets searched in the database field ROHRBEZEICHNUNG (caseinsensitive and via like match)

if both Inputs were filled, the where String continues with "and"

field #2 (schiebersearch2) gets searched in the database field SCHIEBERNUMMER

see below (hope that makes sense)

Solution 1 is much easier, if you have control over your data

-----------------------------------

var schieberSearch = new Query();

schieberSearch.where="";

[...]

schieberSearch.where="lower(ROHRBEZEICHNUNG) like '" + dojo.byId("schiebersearch1").value.toLowerCase() + "%'";

if(dojo.byId("schiebersearch2").value.length>0){

if(schieberSearch.where.length>0)

schieberSearch.where=schieberSearch.where + " and ";

}

schieberSearch.where=schieberSearch.where +"SCHIEBERNUMMER like '"+dojo.byId("schiebersearch2").value+"%'";