I'm using a modified version of the CMV application and I'm trying to alter the query used by the suggestions query of a search widget. The suggestQueryParamters seems to allow for a custom where clause but I can't find any documentation on how to use it.

I want to alter the query from using wildcards on both sides of the search sting (the default) to only using it on the right side of the string i.e.

where field like '{value}%' instead of

where field like '%{value}%' 

In my code below you can see where I try to build a suggestQueryParams object into the sources property but it isn't having any effect. I'm guessing there is something wrong with the construction of the suggestQueryParams object but I can't find anything about constructing it correctly.

            this.searchDijit.on("load", function () {
            var sources = [
                          featureLayer: new FeatureLayer("http://MyTestServer.amazonaws.com/arcgis/rest/services/clinrt/Building_XY/MapServer/0", {
                            outFields: ["*"],
                            //infoTemplate: new InfoTemplate("Parcels", "Number: ${ADDRESS}</br>Street: ${NAME}</br>Full_Address: ${Full_Address}")
                          outFields: ["Full_Address"],
                          displayField: "Full_Address",
                          suggestionTemplate: "${Full_Address}",
                          name: "Parcels",
                          placeholder: "example: 1 CIVIC CENTER PLZ",
                          enableSuggestions: true,
                          maxSuggestions: 50,
                          suggestQueryParams: {where: 'upper(Full_Address) Like \'[value]%\'' }


            //Set the sources above to the search widget
            this.set("sources", sources);
            this.set("activeSourceIndex", 0);

Update So while I couldn't find a way to alter the query that the search widget uses I did find a why to do what I wanted. I found that I could listen for the results event and alter the suggestion list box to remove the items I didn't want. It's not the prettiest or the most efficient way but it works:

            this.searchDijit.on( 'suggest-results', lang.hitch(
                this, function (e) {

                //console.log('suggest results', e);
                var itemi = this.searchDijit.suggestionsNode.children[0].children[0];
                if (!itemi.childNodes || itemi.childNodes.length == 0) return;
                //Here is the logic to remove unwanted items from the list of returned suggestions
                for (var i=0; li=itemi.childNodes[i]; i++) {
                    if(!isNaN(e.value) &&  li.innerText.indexOf(e.value) != 0){
                        i = i -1;

You may not be able to do that using the where clause. In the link you provided, the docs say "Some of these options may be overwritten by the search widget including the following:"

  • outSpatialReference
  • returnGeometry
  • num
  • outFields
  • where
  • maxAllowableOffset
  • objectIds
  • oops looks like I have a comrehension problem, I read that as setting these values would override the widget. D'Oh. – Dowlers May 13 '16 at 21:36
  • So....... how hard is it to extent an ESRI widget? – Dowlers May 13 '16 at 21:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.