Logo

Selectable rows

<v-data-table
  v-model="selected"
  :headers="headers"
  :items="desserts"
  :single-select="singleSelect"
  item-key="name"
  show-select
  class="elevation-1"
>
  <template v-slot:top>
    <v-switch v-model="singleSelect" label="Single select" class="pa-3"></v-switch>
  </template>
</v-data-table>

The show-select prop will render a checkbox in the default header to toggle all rows, and a checkbox for each default row. You can customize these with the slots header.data-table-select and item.data-table-select respectively. You can also switch between allowing multiple selected rows at the same time or just one with the single-select prop.

Dessert (100g serving)CaloriesFat (g)Carbs (g)Protein (g)Iron (%)
Frozen Yogurt15962441%
Ice cream sandwich2379374.31%
Eclair262162367%
Cupcake3053.7674.38%
Gingerbread35616493.916%
Jelly bean37509400%
Lollipop3920.29802%
Honeycomb4083.2876.545%
Donut45225514.922%
KitKat518266576%

Grouped rows

<v-data-table
  :headers="headers"
  :items="desserts"
  item-key="name"
  group-by="category"
  class="elevation-1"
  show-group-by
></v-data-table>

Using the group-by and group-desc props you can group rows on an item property. The show-group-by prop will show a group button in the default header.

Dessert (100g serving)group
category: Candy
Jelly bean
Lollipop
KitKat
category: Cookie
Eclair
Gingerbread
category: Ice cream
Frozen Yogurt
Ice cream sandwich
category: Pastry
Cupcake
Donut
category: Toffee
Honeycomb

Sort on multiple columns

<v-data-table
  :headers="headers"
  :items="desserts"
  :sort-by="['calories', 'fat']"
  :sort-desc="[false, true]"
  multi-sort
  class="elevation-1"
></v-data-table>

Using the multi-sort prop will enable you to sort on multiple columns at the same time. When enabled, you can pass arrays to both sort-by and sort-desc to programmatically control the sorting, instead of single values.

Dessert (100g serving)Calories1Fat (g)2Carbs (g)Protein (g)Iron (%)
Ice cream sandwich2009374.31%
Frozen Yogurt20062441%
Eclair300162367%
Cupcake3003.7674.38%
Gingerbread40016493.916%
Honeycomb4003.2876.545%
Lollipop4000.29802%
Jelly bean40009400%
KitKat500266576%
Donut50025514.922%

Search

<v-card>
  <v-card-title>
    Nutrition
    <v-spacer></v-spacer>
    <v-text-field
      v-model="search"
      append-icon="search"
      label="Search"
      single-line
      hide-details
    ></v-text-field>
  </v-card-title>
  <v-data-table
    :headers="headers"
    :items="desserts"
    :search="search"
  ></v-data-table>
</v-card>

The data table exposes a search prop that allows you to filter your data.

Nutrition
Dessert (100g serving)CaloriesFat (g)Carbs (g)Protein (g)Iron (%)
Frozen Yogurt15962441%
Ice cream sandwich2379374.31%
Eclair262162367%
Cupcake3053.7674.38%
Gingerbread35616493.916%
Jelly bean37509400%
Lollipop3920.29802%
Honeycomb4083.2876.545%
Donut45225514.922%
KitKat518266576%