-
Notifications
You must be signed in to change notification settings - Fork 328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dropdown menus not working as expected #1341
Labels
question
Question
Comments
By setting Try this instead: @app("/demo")
async def serve(q: Q):
# Display dropdown menu
q.page["input"] = ui.form_card(
box="1 1 2 2",
items=[
ui.dropdown(
name="agg_stat",
label="Input",
value=q.args.agg_stat or "median", # check for the new value
trigger=True,
choices=[
ui.choice(name="median", label="Median"),
ui.choice(name="mean", label="Mean"),
ui.choice(name="max", label="Max"),
],
)
],
)
q.page["output"] = ui.frame_card(
box="1 2 2 2", title="Output", content=q.args.agg_stat or "median"
)
await q.page.save() |
Or even better, update instead of recreate: @app("/demo")
async def serve(q: Q):
# Create the cards only once.
if not q.client.initialized:
q.page["input"] = ui.form_card(
box="1 1 2 2",
items=[
ui.dropdown(
name="agg_stat",
label="Input",
value="median", # set default value
trigger=True,
choices=[
ui.choice(name="median", label="Median"),
ui.choice(name="mean", label="Mean"),
ui.choice(name="max", label="Max"),
],
)
],
)
q.page["output"] = ui.frame_card(
box="1 2 2 2", title="Output", content="median"
)
q.client.initialized = True
# Do not recreate, just update if dropdown val changed.
if q.args.agg_stat:
q.page['output'].content = q.args.agg_stat
await q.page.save() |
This is exactly what I was looking for! Got confused with all the |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have created pages
input
andoutput
. I want to select theinput
from the dropdown menu and render it as text in theoutput
page. This does not work very well.If I do not set an initial
ui.dropdown(value=???)
,input
remains blank even if I select items. If I select items, they are successfully rendered inouput
. Here we see 'max' is displayed.Desired behavior:
input
should be displayed when I select it.The following info is linked to #1154 but I've added extra picture explanations (since what is displayed by the dropdown is also incorrect)
If I set
ui.dropdown(value='median')
it initially displaysinput
as Median andoutput
as 'Nothing to render'.Desired behavior: Initial values of
input
andoutput
should correspond to the value set inui.dropdown(value='median')
If I select 'median', it doesn't change
output
.If I select an element that is not median - i.e. not the initial
value
-input
continues to display Median andoutput
successfully displays the selected element. If I then select 'median',input
continues to display Median andoutput
remains whatever it was before.Desired behavior:
input
andoutput
should update simultaneously. Selecting the initialvalue
should updateoutput
the same as selecting elements that are not the initialvalue
.Code to reproduce behaviour
I am using wave version 0.20.0 on Mac with Anaconda install
The text was updated successfully, but these errors were encountered: