Skip to content

How to access buttons created via table slot? #3875

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

You must be logged in to vote

You can add an "enabled" field to the row data and use it in your slot template:

table = ui.table(
    columns=[
        {'name': 'name', 'label': 'Name', 'field': 'name'},
        {'name': 'age', 'label': 'Age', 'field': 'age'},
        {'name': 'buttons', 'label': '', 'field': 'buttons'},
    ],
    rows=[
        {'id': '0', 'name': 'Bob', 'age': 34, 'enabled': True},
        {'id': '1', 'name': 'Jill', 'age': 35, 'enabled': True},
    ],
)
table.add_slot(name='body-cell-buttons', template=r'''
    <q-td :props="props" colspan="100%">
        <q-btn icon="edit" flat dense :disable="!props.row.enabled" />
        <q-btn icon="people" flat dense :disable="!props.row.enabled" />
    </q-td>

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@falkoschindler
Comment options

@vahuynh12
Comment options

Comment options

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

Answer selected by vahuynh12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants