Search on listbox - Forum

Forum Navigation
You need to log in to create posts and topics.

Search on listbox

Hello, How to search on listbox dynamically  ?

for example i have a table that contain 7 records :

Spain

France

Argentine

Indonesia

Malaysia

USA

UK ,

when i am typing on listbox 'u' then only USA and UK that show on the listbox, based on user typo

thank you

When a listbox has the focus and keys are pressed, the behaviour is to search from the start of the text of each item, as far as I know, that is the only way that a regular listbox works in a browser.

If you want to something different, maybe you could add your own text input where the text to search for is entered, and you could write a script to loop though all the items in the list box, and then select the one that matches according to any criteria that you like.

luishp and javadrajabihakami have reacted to this post.
luishpjavadrajabihakami

@suyonob
@susan

@luishp

Here are my observations ...

When a listbox has the focus and keys are pressed, the behaviour is to search from the start of the text of each item

When I pressed U, it selected USA; when I pressed U again, it selected UK ... looks like search begins at the current selection.

If you want to something different, maybe you could add your own text input where the text to search for is entered, and you could write a script to loop though all the items in the list box, and then select the one that matches according to any criteria that you like.

I think what suyonob is asking for is that e.g. after pressing U, the list of items available for selection should be reduced to just USA and UK ... you can accomplish this with VisualNEOWin (old NeoBook), but VisualNEOWeb appears to have a defect ... the property named items works fine when hard coded at design time, but if you specify a [variable], it displays one item for each character (I tried it with items separated by commas and \n) ... perhaps Luis can investigate and tell us if this is a defect or not.

So, if it was possible to dynamically change the list of items, it would be possible to do what suyonob is asking for.

Also, I was not clear what suyonob meant when (s)he posted that ...

i have a table that contain 7 records

... what kind of Table ? (on a database on the server  or a neoTable )

Quote from Gaev on August 2, 2023, 9:19 pm

if it was possible to dynamically change the list of items

The ListExample.neoapp in the Sample Apps included with VisualNEO Web shows how the contents of a listbox can be changed dynamically.

I don't think there is a defect in VisualNEO Web? It's more that things work differently in a browser and so every object is unlikely to work identically as in VisualNEO Win.

Quote from susan on August 2, 2023, 6:34 am

If you want to something different, maybe you could add your own text input where the text to search for is entered, and you could write a script to loop though all the items in the list box, and then select the one that matches according to any criteria that you like.

I have attached a tiny app (the scripts are in page-enter and change of the text input) that does what I was describing in general terms, maybe someone will find it useful?

Uploaded files:
  • You need to login to have access to uploads.
javadrajabihakami and suyonob have reacted to this post.
javadrajabihakamisuyonob

Right like this, Thank you very much for your support @susan and @gaev.

Wonderful Sample

 

 

susan has reacted to this post.
susan

@susan
@suyonob
@luishp

I don't think there is a defect in VisualNEO Web? It's more that things work differently in a browser and so every object is unlikely to work identically as in VisualNEO Win.

Didn't think to look at samples ... ListBox items are stored as array items ... thanks for the tip.

However, when I typed u, I got a whole bunch of items that contained (not just started with) the letter u ... it was only when I followed through with the letter k that it showed Ukraine.

It might be better to search the array items for a match starting at position 0 ... e.g.

If [foundIndex] = 0

 

Thanks again.

susan has reacted to this post.
susan
Quote from Gaev on August 3, 2023, 4:28 am

It might be better to search the array items for a match starting at position 0 ... e.g.

You are very welcome, I love solving problems.

About your comment, what works best depends?

Having it search so that the user types any part of the name of a country, was intentional. With a list of countries like this, it is possible for a user to not know the first letter that they need to type. For example, if I want to find South Korea, do I start typing "Korea" or "South"?

With the search in my tiny app, it doesn't matter which, I will quickly find the country, which (I think) is better.

I agree that in some cases your suggestion of only searching from the start of the words in the list would be precisely what is required.

 

luishp has reacted to this post.
luishp

Interesting thread :)
Just note linstboxes behaviour is enterely controled by the web browser.
I mean, it's a web browser built-in object.