Invert default selection from all to empty in selectors with multiple activated #592
-
Is there a way to invert the default selections from all to empty when using a selector with multiple ? I would like to build a filter that works by starting with no constraints and then applying new ones, rather than the other way around (all options selected by default). The list I would be putting into the dropdown is fairly large and I would rather select the one or two options I want at any given time as opposed to remove the 10's of options I don't. My code snippet to build the selector is as follows ` <|{mooring_id}|selector|lov={mooring_ids}|multiple|label=Select the Mooring ID|dropdown|on_change=on_filter|class_name=fullwidth|> |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
You have initialized your selection to be all the selector values in your code. You can initialize it to None to solve your issue: from taipy.gui import Gui
mooring_ids = [f"Choice {i}" for i in range(100)]
mooring_id = None
md = "<|{mooring_id}|selector|lov={mooring_ids}|multiple|label=Select the Mooring ID|dropdown|on_change=on_filter|class_name=fullwidth|>"
def on_filter(state):
print(state.mooring_id)
Gui(md).run() |
Beta Was this translation helpful? Give feedback.
-
I did have to put it in an empty list but otherwise this is exactly what I wanted. Thanks mooring_id = None became mooring_id = [None] |
Beta Was this translation helpful? Give feedback.
You have initialized your selection to be all the selector values in your code. You can initialize it to None to solve your issue: