Skip to content

How to set class on table rows or cells #4103

Closed Answered by falkoschindler
ed2050 asked this question in Q&A
Discussion options

You must be logged in to vote

I don't think there is an easy way to define dynamic classes on QTable rows. But you can either overwrite the "body" slot to define the look of individual rows from ground up, or you use the "classes" field for column definitions to defined row-dependent column classes:

columns = [
    {'name': 'name', 'label': 'Name', 'field': 'name', ':classes': '(row) => row.classes'},
    {'name': 'age', 'label': 'Age', 'field': 'age', ':classes': '(row) => row.classes'},
]
rows = [
    {'name': 'Alice', 'age': 18, 'classes': 'text-blue'},
    {'name': 'Bob', 'age': 21, 'classes': 'text-red'},
]
ui.table(columns=columns, rows=rows)

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@ed2050
Comment options

Answer selected by ed2050
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants