Table component cell slots may no longer require Vue string templates. #3148
Replies: 4 comments 4 replies
-
Oh WOW! This would be amazing, @CrystalWindSnake! Your demo already looks very promising. 🚀 This would resolve discussions like #846, #1138, #2080, and #2625. Maybe we can nest the slot and argument type in the table = ui.table(...)
@table.cell_slot("name")
def _(args: ui.table.CellSlotProps):
... or simply: @table.cell_slot("name")
def _(row_index: int, name: str):
... Anyway, I'm very much looking forward to your pull request. 🙂 |
Beta Was this translation helpful? Give feedback.
This comment was marked as off-topic.
This comment was marked as off-topic.
-
VERY cool! Is it going by any chance to work not only in |
Beta Was this translation helpful? Give feedback.
-
For #3794 I needed to write a small demo where a colors = ['red', 'green', 'blue']
columns = [
{'name': 'product', 'label': 'Product', 'field': 'product', 'align': 'center'},
{'name': 'color', 'label': 'Color', 'field': 'color', 'align': 'center'},
]
rows = [
{'product': 'A', 'color': 'red'},
{'product': 'B', 'color': 'green'},
{'product': 'C', 'color': 'blue'},
]
table = ui.table(columns=columns, rows=rows, row_key='product').classes('w-72')
table.add_slot('body-cell-color', r'''<q-td key="color" :props="props"></q-td>''')
for r, row in enumerate(rows):
with ui.teleport(f'#c{table.id} tr:nth-child({r+1}) td:nth-child(2)'):
ui.select(colors).bind_value(row, 'color') Is this something we could improve with |
Beta Was this translation helpful? Give feedback.
-
I accidentally discovered that Vue 3 has a component called
teleport
that allows specifying a component to render anywhere on the page. I vaguely feel that by leveraging this component's features, we can use any NiceGUI component instance directly in table cell slots without writing Vue string templates.a simple demo repository.
The usage example :
I will fix some issues and submit the corresponding PR, in the coming days.
Todo list:
teleport
component (a separate PR)options
slot for the select component.flowchart
If you has any ideas or suggestions, please let me know.
Beta Was this translation helpful? Give feedback.
All reactions