We are currently using the Dropdown Search widget, and we are facing an issue where we do not want the search input to trim spaces.
For example, if we have a value like “Dog”, and the user searches with “Do ” with one trailing space, we want the Dropdown Search to return no results. However, currently it seems that the widget ignores the space and trims it out before searching.
As shown in the image, we would like to know how we can solve this issue, or whether there is a way to prevent the Dropdown Search from trimming spaces in the search keyword.
Hello @sahatsawat kthasattapich,
I believe this is how the Dropdown Search from OutSystemsUI works. You may want to consider creating your own customized dropdown with the same search behavior and design. You can even reuse or copy the OutSystemsUI implementation and modify it based on your requirements.
The dropdown search itself would execute a query similar to this:
WHERE
@SearchValue = LTRIM(RTRIM(@SearchValue))
AND YourColumn LIKE '%' + @SearchValue + '%'
What happens here is the following:
If the user types something like ' Do ' and you have a record such as 'Dog' in the database, the first condition checks whether the search input contains any leading or trailing spaces.
In this case:
On the other hand, if the input does not contain leading or trailing spaces, the first condition passes, and the second condition is then responsible for performing the actual search using the LIKE statement.
Thank you so much. I have now changed it to a server-side dropdown with a custom search text implementation.I think it may not be possible to fully change the behavior of the default Dropdown Search widget.
You're very welcome.
It can be done, but it would require significantly more effort. The easier approach would be to create your own implementation and add it as a new pattern inside _Pat module.