Closed Zedmor closed 4 years ago
Hello @Zedmor,
Thanks for approaching the conditional sidebar issue #398.
When I run your fork, I obtain a dash.exceptions.DuplicateCallbackOutput:
Multi output ..location.hash...population.value... [...]. contains an `Output` object
that was already assigned.
Duplicates:
{'doubling_time.value', 'date_first_hospitalized.date'}
I believe it should be possible to use the disabled
tag of input forms to avoid overriding existing tags, e.g.,
As an initial draft, this should work (I have some issues with the switch widget states if the `URL parameter callbacks are turned on though).
# in SidebarCallbacks.__init__
def pick_hospitalized_checkbox(form_value):
pick_date = # some logic depending on form_value
return [pick_date, not pick_date]
# add to callbacks
ChimeCallback(
changed_elements={'pick_hospitalized_checkbox': 'value'},
dom_updates={'date_first_hospitalized': 'disabled', 'doubling_time': 'disabled'},
callback_fn=pick_hospitalized_checkbox
)
# in SidebarCallbacks.update_parameters
pick_hospitalized_checkbox = inputs_dict.get("pick_hospitalized_checkbox", False)
dt = inputs_dict["doubling_time"] if not pick_hospitalized_checkbox else None
dfh = inputs_dict["date_first_hospitalized"] if pick_hospitalized_checkbox else None
Let me know if you want to pick up on this (e.g., PR on your fork) or do you have another idea?
I am trying to make conditional clear/hide on components in sidebar but can't figure out good hook. I created toggles and put a callback to either populate value with Null or except and bail on request, but all sidebar inputs are populated from store which is populated by URL and now I am lost :disappointed:
I think I finished this feature and it works as expected locally
This complete feature for the conditional sidebar.