Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(VDataTable): add mobile view #19431

Merged
merged 79 commits into from Apr 29, 2024

Conversation

webdevnerdstuff
Copy link
Contributor

@webdevnerdstuff webdevnerdstuff commented Mar 19, 2024

Description

Adds a mobile view for the data tables

Ref Issue: #16784

Markup:

<template>
  <v-data-table
    v-model:expanded="expanded"
    :fixed-header="true"
    :headers="headers"
    :items="desserts"
    :mobile="smAndDown"
    :multi-sort="false"
    item-value="name"
    items-per-page="5"
    theme="dark"
    show-expand
    show-select
  >
    <template #[`header.name`]>
      name header slot
    </template>
    <template #[`item.calories`]>
      calories item slot
    </template>
    <template #expanded-row="{ index, columns }">
      <tr>
        <td :colspan="columns.length">
          Index: {{ index }} Expanded Row
        </td>
      </tr>
    </template>
  </v-data-table>
</template>

<script setup lang="ts">
  import { ref } from 'vue'
  import { useDisplay } from 'vuetify'

  const { smAndDown } = useDisplay()

  const expanded = ref([])
  const headers = ref([
    {
      title: 'Dessert (100g serving)',
      align: 'start',
      sortable: false,
      key: 'name',
    },
    { title: 'Calories', key: 'calories' },
    { title: 'Fat (g)', key: 'fat' },
    { title: '', key: 'data-table-expand' },
  ] as const)
  const desserts = ref([
    {
      name: 'Frozen Yogurt',
      calories: 159,
      fat: 6,
    },
    {
      name: 'Ice cream sandwich with some really long name',
      calories: 237,
      fat: 9,
    },
    {
      name: 'Eclair',
      calories: 262,
      fat: 16,
    },
    {
      name: 'Cupcake',
      calories: 305,
      fat: 3.7,
    },
    {
      name: 'Gingerbread',
      calories: 356,
      fat: 16,
    },
    {
      name: 'Jelly bean',
      calories: 375,
      fat: 0,
    },
    {
      name: 'Lollipop',
      calories: 392,
      fat: 0.2,
    },
    {
      name: 'Honeycomb',
      calories: 408,
      fat: 3.2,
    },
    {
      name: 'Donut',
      calories: 452,
      fat: 25,
    },
    {
      name: 'KitKat',
      calories: 518,
      fat: 26,
    },
  ])
</script>

@webdevnerdstuff webdevnerdstuff changed the title feat/data table mobile view feat(VDataTable): Adds a mobile view for data tables Mar 19, 2024
@MajesticPotatoe MajesticPotatoe added T: feature A new feature C: VDataTable VDatatable labels Mar 19, 2024
@MajesticPotatoe
Copy link
Member

Rebase to dev

@johnleider johnleider force-pushed the feat/data-table-mobile-view branch 3 times, most recently from 9e109f1 to 29509fd Compare April 26, 2024 22:29
johnleider
johnleider previously approved these changes Apr 26, 2024
johnleider
johnleider previously approved these changes Apr 27, 2024
@yuwu9145
Copy link
Member

  • Missing "select all" checkbox
  • Item checkbox is left-aligned

V2 mobile screenshot (white background) is attached for comparison

Screenshot 2024-04-28 at 11 36 22 am Screenshot 2024-04-28 at 11 43 37 am

@webdevnerdstuff
Copy link
Contributor Author

I fixed the alignment to be end for the checkbox. As for the header one, I'll chat with John about what to do with that, as personally I think it looks kind of weird next to the sortby.

@johnleider johnleider merged commit 66880ce into vuetifyjs:dev Apr 29, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: VDataTable VDatatable T: feature A new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants