Search Box

Questions and answers on designing your Servoy solutions, database modelling and other 'how do I do this' that don't fit in any of the other categories

Search Box

Postby Robin.Lanneer » Tue Mar 28, 2017 4:12 pm

Hello

I am trying to make a search box in our appilcation, something like google really.
When our users type something i want them to see some suggestions or autocompletes, so when they select one of the suggestions it shows the correct record.
However i also want an option where the user doesn't select one of the suggestions and then i want to show all of the results for this search query in a list.
I made a type ahead field in which users can type their "query", the type ahead then sends a rest call to my search engine. The search engine sends its best results back to the application.
The top 5 results then appear in the suggestion box of the type ahead. (they are in the valueList of the typeahead).
However the type ahead automatically selects the first one, i would like to give the users the ability to press enter (when nothing is selected) so that a list appears which contains all of the results (not just top 5).
If the user does select a suggestion it should open the selected record. Otherwise a list with all the results, from which the user can select the correct record(s).
The results of my search engine contains the id which is used in the database.

So my question is can i use type ahead that doesn't automatically select one its values, so that when you press enter it can execute another method(to call my search engine for all the results), and storing them in a listbox.
Robin.Lanneer
 
Posts: 4
Joined: Tue Mar 28, 2017 11:26 am

Re: Search Box

Postby Bernd.N » Tue Mar 28, 2017 4:40 pm

When you press enter on a field, the onDataChange() event of that field fires, in case the field value got changed.
In that function you can start fresh and do whatever you want, like calling your searchEngine.

The typeahead field selects a value from the list that it shows only when you press Enter.
But when you press the --> (Tab) button on your keyboard, you will not select a value but stay with the value that you already entered.
Does that help you?

For large amounts of data, we do not use a typeahead but the picklist from Servoy Forge, it might be an idea for what you are going to do, too.
https://www.servoyforge.net/projects/mod-listpicker
Bernd Korthaus
LinkedIn
Servoy 7.4.9 SC postgreSQL 9.4.11 Windows 10 Pro
User avatar
Bernd.N
 
Posts: 544
Joined: Mon Oct 21, 2013 5:57 pm
Location: Langenhorn, North Friesland, Germany


Return to Programming with Servoy

Who is online

Users browsing this forum: No registered users and 13 guests

cron