How to make the dropdown component enable the user to start writing on it with an auto-complete feature, there is an app in the forum with this feature by @navigate:
for text box input, but, I can’t do that with the dropdown component, because it only allows selection not writing.
Any suggestion?
But I just can’t figure out how to edit how results are displayed.
Searching is great, I found out how to search throught multiple data table columns etc.:
This is what it does when I select result:
But maybe because it uses external library “Search Hints” I can’t figure out how to achieve this, I need the result in the same field, beacuase it is part of form to get t-shirt quote (I can publish all app if needed):
If somebody could point me in a right direction, it could be great.
If so, you can modify the set_result function in the “Search Hints” app, like this:
def set_result(self, result, **event_args):
"""Set the result in the result box."""
self.raise_event('x-search-hints-result', result=result)
self.repeating_panel_results.items = []
self.text_box_search.text=result # modification to send result to the search box (i.e., the TextBox component)
You always have access to the result that is displayed at the bottom (“Selected Tool: X”), but certainly if you do not want it to show up there, you can remove those components altogether, and still keep track of the result.
For example, if you want to keep track of the selected result, you can always stick it on a tag somewhere, like the following which saves the result to a tag (it is also being printed out just for clarity):
I did this by modifying the update_result_label function in the main app (I’ve renamed it to save_current_result), as follows:
# was originally named "update_result_label"
def save_current_result(self, result, **event_args):
"""Set the result label on this Form to the selected search result."""
self.search_hints_1.tag.my_new_result=result # saving the result by "sticking" it to a component
print(self.search_hints_1.tag.my_new_result)
#self.label_result.text = result
I am not certain that this is what you are trying to accomplish, so please clarify if that is the case.
I tried to open the component @campopianoa referred to, but it doesn’t work anymore, at least not for me.
I have a clone of it here:
There is a container form that has the component search_hints_1, which has its get_keys_function set to get_search_keys. ServerModule1 contains the callable function get_search_keys, which just returns a list of strings.
When I try to search something that should match the strings returned by get_search_key, I instead see this error on the command:
`TypeError: 'NoneType' object is not iterable`
* `at SearchHints, line 43`
* `called from SearchHints, line 26`
I also tried using a fresh clone of it as a app dependency, which predictably had similar results.
Am I misunderstanding how to use this component or is this component now broken?
In this example you’ll see that you need to set an event handler for “x-get-search-keys” which should return an iterable where each item has an “entry” field
This could be a list of dicts
or a search iterator
Yes, I think returning from an event handler was what tripped me up. I just added those lines of code in the my Container form and it behaves as expected. Thank you I didn’t realize events in Anvil can be used like that.