JS 4.x display search results

1281
7
10-03-2018 08:34 AM
City_of_Greenville__SCGIS
New Contributor III

I'm looking for a simple way to display the search results, Fall For Greenville.

I know I have to turn off the autoSelect and use the search-complete event but I don't really understand what this means.  I can use the below to log it in the console but how do I do anything with it the search-complete?

searchWidget.on("search-complete", function(event){
  // The results are stored in the event Object[]
  console.log("Results of the search: ", event);
});

Scott

0 Kudos
7 Replies
RobertScheitlin__GISP
MVP Emeritus

Scott,

   What is it that you want to do with the search results?

0 Kudos
City_of_Greenville__SCGIS
New Contributor III

Just display them and let users select.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

When a user types in a search term and you have autoSelect set to true then they are not presented with the results list it just automatically goes to the first result.

0 Kudos
City_of_Greenville__SCGIS
New Contributor III

I'm looking to set it to false and be presented with the list, similar to what it does for suggestions.  

I could potentially use the default template which has "Show More Results" but the results are limited.  In the case below, the more results are limited to five but in reality there are more than 40 results that would apply

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

OK,

   Then you will have to loop through the results from the search-complete event handler and use something like dojo domConstruct to build html elements to display to the end user and attach events to those elements for zooming etc. Sorry no easy solution to this.

0 Kudos
City_of_Greenville__SCGIS
New Contributor III

Yeah that seems way out of my depth and not worth the input.  Seems crazy to me that results table would be that hard but then again I don't know what I don't know so...

Any way to expand the "more results" from the default popup?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

You can set featureNavigationEnabled on the views popup.

Popup | API Reference | ArcGIS API for JavaScript 4.9 

0 Kudos