Consider following code based on https://vuetifyjs.com/en/components/data-tables/#grouping
// Disable annoying tips:
Vue.config.devtools = false
Vue.config.productionTip = false
new Vue({
el: '#app',
vuetify: new Vuetify(),
data () {
return {
search: '',
headers: [
{
text: 'Dessert (100g serving)',
align: 'start',
value: 'name',
groupable: false,
},
{ text: 'Category', value: 'category', align: 'right' },
{ text: 'Dairy', value: 'dairy', align: 'right' },
{ text: 'Calories', value: 'dairy', align: 'right' },
{ text: 'Fat (g)', value: 'calories' },
{ text: 'Carbs (g)', value: 'carbs' },
{ text: 'Protein (g)', value: 'protein' },
{ text: 'Iron (%)', value: 'iron' },
],
desserts: [
{
name: 'Frozen Yogurt',
category: 'Ice cream',
dairy: 'Yes',
calories: 159,
fat: 6.0,
carbs: 24,
protein: 4.0,
iron: '1%',
},
{
name: 'Eclair',
category: 'Cookie',
dairy: 'Yes',
calories: 262,
fat: 16.0,
carbs: 23,
protein: 6.0,
iron: '7%',
},
{
name: 'Cupcake',
category: 'Pastry',
dairy: 'Yes',
name: 'Cupcake',
calories: 305,
fat: 3.7,
carbs: 67,
protein: 4.3,
iron: '8%',
},
{
name: 'Gingerbread',
category: 'Cookie',
dairy: 'No',
calories: 356,
fat: 16.0,
carbs: 49,
protein: 3.9,
iron: '16%',
},
{
name: 'Jelly bean',
category: 'Candy',
dairy: 'No',
name: 'Jelly bean',
calories: 375,
fat: 0.0,
carbs: 94,
protein: 0.0,
iron: '0%',
},
{
name: 'Lollipop',
category: 'Candy',
dairy: 'No',
name: 'Lollipop',
calories: 392,
fat: 0.2,
carbs: 98,
protein: 0,
iron: '2%',
},
{
name: 'Honeycomb',
category: 'Toffee',
dairy: 'No',
calories: 408,
fat: 3.2,
carbs: 87,
protein: 6.5,
iron: '45%',
},
{
name: 'Donut',
category: 'Pastry',
dairy: 'Yes',
calories: 452,
fat: 25.0,
carbs: 51,
protein: 4.9,
iron: '22%',
},
{
name: 'KitKat',
category: 'Candy',
dairy: 'Yes',
calories: 518,
fat: 26.0,
carbs: 65,
protein: 7,
iron: '6%',
},
{
name: 'Ice cream sandwich',
category: 'Ice cream',
dairy: 'Yes',
calories: 237,
fat: 9.0,
carbs: 37,
protein: 4.3,
iron: '1%',
},
],
}
},
})
<link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/@mdi/font@4.x/css/materialdesignicons.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/vuetify@2.4.8/dist/vuetify.min.css" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">
<div id="app">
<v-app id="inspire">
<v-card>
<v-card-title>
<v-text-field
v-model="search"
append-icon="mdi-magnify"
label="Search"
single-line
hide-details
></v-text-field>
</v-card-title>
<v-data-table
:headers="headers"
:items="desserts"
item-key="name"
:search="search"
sort-by="name"
group-by="category"
class="elevation-1"
show-group-by
mobile-breakpoint=100000
:header-props="{'disable-sort': true}"
></v-data-table>
</v-card>
</v-app>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.12/dist/vue.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vuetify@2.4.8/dist/vuetify.js"></script>
Click Run code snippet and on Full page to see it better.
If you prefer codepen, click here.
I have enforced the mobile/responsive version of the <v-data-table> component of vuetify by setting mobile-breakpoint to 100000. The default is 600 which corresponds to the breakpoint xs.
I would like to hide the dropdown menu for sorting for the mobile view but leave sorting active for grouping functionality and also for Desktop/Tablet viewer.
I have added
:disable-sort="$vuetify.breakpoint.xsOnly"
// or here simply since we consider only the mobile version:
disable-sort
However, this breaks the grouping.
Other tries were
:hide-default-header="$vuetify.breakpoint.xsOnly"which removes the description of the entries which I do not want.:header-props="{'disable-sort': true}"which does nothing
Vuetify version: 2.4.8 with Vue 2.6.12.
UPDATE Clarification that the column headers should stay but only the dropdown for sorting in the responsive view should be removed:
