-
-
Notifications
You must be signed in to change notification settings - Fork 516
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
Add simple nested editor to Tabulator #7251
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7251 +/- ##
==========================================
- Coverage 82.23% 82.23% -0.01%
==========================================
Files 337 337
Lines 50251 50317 +66
==========================================
+ Hits 41325 41379 +54
- Misses 8926 8938 +12 ☔ View full report in Codecov by Sentry. |
panel/models/tabulator.ts
Outdated
const row = cell.getRow().getData() | ||
let values = editorParams.options | ||
for (const i of editorParams.lookup_order) { | ||
values = values[row[i]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if there is no entry here? Does it handle it gracefully?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Asked on clarifying question, otherwise this looks great!
7ec216c
to
81389c8
Compare
This is an alternative example in an attempt to make it more clear which columns contains the nested selections and how the options depends on the selections in other columns. Its also more verbose, so its not clear to me if I should contribute this as and improvement to the docs. Thus I just persist it here for now. nested-selections.mp4import pandas as pd
import panel as pn
pn.extension("tabulator")
df = pd.DataFrame({"0": ["A", "B", "A"], "1": [1, 2, 3], "Nested Selection": [None, None, None]})
options = {
"A": ["A.1", "A.2", "A.3", "A.4", "A.5"],
"B": {
"1": ["B1.1", "B1.2", "B1.3"],
"2": ["B2.1", "B2.2", "B2.3"],
"3": ["B3.1", "B3.2", "B3.3"],
},
}
tabulator_editors = {
"0": {"type": "list", "values": ["A", "B"]},
"1": {"type": "list", "values": [1, 2, 3]},
"Nested Selection": {"type": "nested", "options": options, "lookup_order": ["0", "1"]},
}
def on_edit(event):
if event.column in ("0", "1"):
edit_table.patch({"Nested Selection": [(event.row, None)]})
edit_table = pn.widgets.Tabulator(df, editors=tabulator_editors, show_index=False, on_edit=on_edit)
edit_table.servable() |
I think it is a better example, so you are welcome to open a PR with your suggested changes. |
Screencast.2024-09-10.18.57.55.mp4