How to make the item(the whole row) clickable #14827
Unanswered
muhammadafif133
asked this question in
Q&A
Replies: 2 comments 3 replies
-
Hi. Use the "item" slot: https://vuetifyjs.com/en/api/v-data-table/#slots-item Then, in the "tr" element, add a click event like so: <v-data-table :headers="headers" :items="items">
<template v-slot:[`item`]='{ item }'>
<tr @click="yourFunction">
<td>{{ item.something1 }}</td>
<td>{{ item.something2 }}</td>
<td>{{ item.something3 }}</td>
</tr>
</template>
</v-data-table> |
Beta Was this translation helpful? Give feedback.
0 replies
-
I had been doing this as above, but just found a much better way to do this.
const headers = [
{ key: 'type', title: 'Type', value: (item: any, fallback?: any) => getTypeEnumString(item.type) },
...
] This has the added benefit of making sorting and filtering work as expected.
<v-data-table :headers="headers" @click:row="openEditDialog" /> The table even shows a nice pointing-hand cursor when the |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
How do I make the whole line clickable instead of clicking the text of the item?
Is it possible to overwrite the items into an anchor tag?
Beta Was this translation helpful? Give feedback.
All reactions