'How to remove the select all option from a v-data-table?
I need to hide the select all option from a v-data-table, the vuetify component. According to the documentation including the header-prop, single-select as true should do it but is not working.
<v-data-table
v-model="selected
:headers="headers"
:items="items"
show-select
:header-props="{singleSelect:true}"
></v-data-table>
Solution 1:[1]
If you want to be able to only select one item at a time you can add single-select
directly to v-data-table
:
<v-data-table
v-model="selected"
:headers="headers"
:items="items"
show-select
single-select
></v-data-table>
If you want to be able to select multiple items you can override the select all checkbox with the header.data-table-select
slot:
<v-data-table
v-model="selected"
:headers="headers"
:items="items"
show-select
>
<template #header.data-table-select></template>
</v-data-table>
Solution 2:[2]
I use slot to overwrite the select-all.
<v-data-table
v-model="selected"
:headers="headers"
:items="items"
show-select
>
<template v-slot:[`header.data-table-select`]></template>
</v-data-table>
and if you could put a title for sue, like this:
<v-data-table
v-model="selected"
:headers="headers"
:items="items"
show-select
>
<template v-slot:[`header.data-table-select`]>Selected</template>
</v-data-table>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Jay Fridge |
Solution 2 | user16582278 |