Show fields in autocomplete but not use them in the search

I’m using an autocomplete and showing a number of fields from the results to give plenty of clarity but I don’t want all the fields to be used in the actual search.

Eg. If I have a list of names and their ages, my dropdown will show ‘Jon aged 21’ but I don’t want it to appear if someone types ‘21’ in the field.

How can I do this?

I also have something slightly different that I think a tweak to Autocomplete might help with as well as this one. At the moment it only has 2 bound data values, the text to display and the value it gives. I propose that a 3rd is added - a search string.

In my case I have users and I want to only show their names but actually be able to search based on other values such as their status.

In my case:
Text to display: {{name}}
Value: {{UserID}}
Search string: {{name+' '+status}}

In Jon’s case it could be:
Text to display: {{name+' ('+age+')'}}
Value: {{UserID}}
Search string: {{name}}

If left blank - to allow compatibility with existing uses of the component, it could default to the display text for the search string.

Would that be possible @george?

1 Like

Try this update. A new attribute optionsearch can be used to set the search string expression.

dmxAutocomplete.zip (2.3 KB)

Thanks Patrick. Almost there. It’s correctly searching only the name now but the dropdown isn’t appearing. If I type something in which should return something, it appears to do nothing. If I type something in which shouldn’t return anything, it shows the ‘No results’ message correctly.

New update: dmxAutocomplete.zip (2.2 KB)

1 Like

Boom! Works perfectly.

Will this make it into the UI for today’s update? :wink:

Update is included in Wappler 4.8.0

1 Like