Trap the Suggest List before it displays.

655
4
Jump to solution
10-20-2020 06:03 AM
AlexRodriguez
New Contributor III

Javascript API, v4.16

Trying to sort the Search Suggestion list beyond a field ASC or DESC.  But first, how do I grab the list before it's displayed?

I need the list, sort it based on my criteria, then display it.

Can I get to that list before it's displayed?

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Alex,

   I have not tried this personally but the normal way would be to listen for the suggest-complete event 

https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#event-suggest... 

and work with the result property.

View solution in original post

0 Kudos
4 Replies
RobertScheitlin__GISP
MVP Emeritus

Alex,

   I have not tried this personally but the normal way would be to listen for the suggest-complete event 

https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#event-suggest... 

and work with the result property.

0 Kudos
AlexRodriguez
New Contributor III

Robert, 

Thanks for your reply.   I've looked at that and that's what I'm playing with now.  But isn't the SUGGEST LIST already displayed by this time?
I'm going to take that list, sort it, then display it again.  I'd like to sort it before it gets displayed so the user doesn't have to wait for a 2nd display.  Is that possible?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Alex,

   The only events you have are suggest-start and suggest-complete. The search widgets listens to these and builds the results list from those events. I am not sure how to accomplish what you are attempting. Maybe work with the suggestions property

https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#suggestions 

inside the listener of one of those events.

AlexRodriguez
New Contributor III

Many Thanks!

0 Kudos