Mandatory fields of ui.table #3729
denniswittich
started this conversation in
Ideas / Feature Requests
Replies: 1 comment
-
I like the idea of allowing to omit certain fields in the rows dicts. We could also infer the label from name (similar as omitting the whole rows parameter): columns = [
{'name': 'name', 'align': 'left'},
{'name': 'age', 'sortable': True},
]
rows = [
{'name': 'Alice', 'age': 18},
{'name': 'Bob', 'age': 21},
{'name': 'Carol'},
]
ui.table(columns=columns, rows=rows, row_key='name')
ui.table(columns=columns, rows=rows, row_key='name') Or the name from label: columns = [
{'label': 'Name', 'align': 'left'},
{'label': 'Age', 'sortable': True},
]
rows = [
{'Name': 'Alice', 'Age': 18},
{'Name': 'Bob', 'Age': 21},
{'Name': 'Carol'},
]
ui.table(columns=columns, rows=rows, row_key='Name')
ui.table(columns=columns, rows=rows, row_key='Name') |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Description
When creating a ui.table with columns one needs to provide
name
,label
andfield
. This seemed a bit redundant first but after some discussions I get thatfield
provides some extra functionalities that can be useful. However, when working with tables for the first time one could forget to setfield
in the columns dict. This modification of the web exampledoes not produce an error but instead a table where the number of lines matches but without any content:
My suggestion is to validate the dictionary and then either default to the
name
iffield
is missing or to throw an error.Beta Was this translation helpful? Give feedback.
All reactions