I have a radiobutton group which toggles the mode from one multiselect filter to other multiselect filter i.e., at a time, only one multiselect filter is active. I am clearing the values and disabling the multiselect filter when I switch to the other. While doing so, I had two concerns:
[1] On toggling, the previous filter is disabled, and when I try to print out the values, nothing gets printed out as expected. But on the UI, I can see the old selection rendering still. So when I toggle again, the old list is shown empty but on the UI, the selection is visible.
[2] If I toggle twice, and select the same values which were selected earlier before the toggle, the result is none/null/empty. I have to select some other value and then select the earlier values to make it effective.
How can I achieve [1] and resolve the bug [2] ?
import panel as pn
pn.extension()
bu_view_selector = pn.widgets.RadioButtonGroup(options=["BU Group", "BU"], button_type="default")
bu_group_filter = pn.widgets.MultiSelect(name="BU Group", options=["BG1", "BG2", "BG3"], max_width=500)
bu_filter = pn.widgets.MultiSelect(name="BU", options=["BU1", "BU2", "BU3"], max_width=500, disabled=True)
button = pn.widgets.Button(name='Click me', button_type='primary')
@pn.depends(bu_view_selector.param.value, watch=True)
def _update_bu_view(view):
if bu_view_selector.value == "BU Group":
bu_group_filter.disabled = False
bu_filter.value.clear()
bu_filter_options = bu_filter.options
else:
bu_filter.disabled = False
bu_group_filter.value.clear()
bu_group_filter.disabled = True
bu_group_filter.select().clear()
def b(event):
print("BU values: ", bu_filter.value)
print("BU group values: ", bu_group_filter.value)
button.on_click(b)
pn.Column(bu_view_selector, pn.Row(bu_group_filter,pn.widgets.StaticText(value="OR", align="center"), bu_filter), button)