Skip to content

Why does ui.context_menu() not work for ui.tree? #4010

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

You must be logged in to vote

I see. The problem seems to be that with ui.tree(): ... want's to populate the tree's default slot, but there is no such slot. Quasar's QTree only has slots for individual node headers and bodies. You can use them to add context menus like this:

tree = ui.tree([
    {'id': 'numbers', 'children': [{'id': '1'}, {'id': '2'}]},
    {'id': 'letters', 'children': [{'id': 'A'}, {'id': 'B'}]},
], label_key='id')
tree.add_slot('default-header', '''
    <span :props="props">Node <strong>{{ props.node.id }}</strong>
        <q-menu touch-position context-menu>
            <q-item clickable v-close-popup @click="() => props.tree.$emit('click_open', props.key)">
                <q-item-section>Open</q…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

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

Answer selected by cwfbss
@cwfbss
Comment options

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