-
Notifications
You must be signed in to change notification settings - Fork 328
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
11 changed files
with
216 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Table / Events / Group | ||
# Register the `group_change` #event to emit Wave event when group collapses or opens. | ||
# #table #events #groups | ||
# --- | ||
from h2o_wave import main, app, Q, ui | ||
|
||
bobrows = [ | ||
{"name":"row1", "cell":"Issue1"}, | ||
{"name":"row2", "cell":"Issue2"}, | ||
] | ||
johnrows = [ | ||
{"name":"row3", "cell":"Issue3"}, | ||
{"name":"row4", "cell":"Issue4"}, | ||
{"name":"row5", "cell":"Issue5"}, | ||
] | ||
|
||
collapsed_states = { | ||
'Bob': True, | ||
'John': False | ||
} | ||
|
||
@app('/demo') | ||
async def serve(q: Q): | ||
if q.events.issues_table and q.events.issues_table.group_change: | ||
# toggle the collapse states | ||
for group in q.events.issues_table.group_change: | ||
collapsed_states[group] = not collapsed_states[group] | ||
q.page['collapse'].content = f'{q.events.issues_table.group_change}' | ||
else: | ||
q.page['form'] = ui.form_card(box='1 1 4 5', items=[ | ||
ui.table( | ||
name='issues_table', | ||
columns=[ui.table_column(name='text', label='Issues assigned to')], | ||
groups=[ | ||
ui.table_group("Bob", | ||
rows=[ui.table_row( | ||
name=row["name"], | ||
cells=[row["cell"]]) | ||
for row in bobrows], | ||
collapsed=collapsed_states["Bob"] | ||
), | ||
ui.table_group("John", | ||
rows=[ui.table_row( | ||
name=row["name"], | ||
cells=[row["cell"]]) | ||
for row in johnrows], | ||
collapsed=collapsed_states["John"] | ||
),], | ||
height='400px', | ||
events=['group_change'] | ||
) | ||
]) | ||
q.page['collapse'] = ui.markdown_card(box='5 1 2 1', title='Group change info', content='') | ||
|
||
q.client.initialized = True | ||
|
||
await q.page.save() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters