Add buttons or context menus to individual tree items #3967
-
QuestionIs it possible to add buttons or context menus to individual tree items? Custom content can be added via slots, but how do I make a raw Quasar element talk to my application? |
Beta Was this translation helpful? Give feedback.
Answered by
falkoschindler
Nov 9, 2024
Replies: 1 comment 1 reply
-
Hi @moi90, Currently the easiest way is to emit an event which is handled by the tree = ui.tree([
{'id': 'numbers', 'description': 'Just some numbers', 'children': [
{'id': '1', 'description': 'The first number'},
{'id': '2', 'description': 'The second number'},
]},
], label_key='id')
tree.add_slot('default-body', '''
<q-btn :props="props" @click="props.tree.$emit('item-click', props.node.description)">Click me</q-btn>
''')
tree.on('item-click', lambda e: ui.notify(e.args)) You can pass any information from |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
falkoschindler
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @moi90,
Currently the easiest way is to emit an event which is handled by the
ui.tree
element:You can pass any information from
props
orprops.node
, respectively. In the QTree documentation you can find more information about theprops
object (QTree API > Slots > def…