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

fix(VDataTable): use item.raw and columns in sorting transform #20077

Conversation

tongxuanbao
Copy link
Contributor

@tongxuanbao tongxuanbao commented Jun 29, 2024

Description

fixes #20045

Markup:

<template>
  <v-data-table
    :group-by="groupBy"
    :headers="headers"
    :items="desserts"
    item-value="name"
  >
  </v-data-table>
</template>

<script>
  export default {
    data() {
      return {
        groupBy: [
          {
            key: 'group.deep', // work with deep key now
            order: 'desc',
          },
        ],
        headers: [
          { title: 'Dessert (100g serving)', key: 'name' },
          { title: 'Calories', key: 'calories' },
          { title: 'Fat (g)', key: 'fat' },
          { title: 'Carbs (g)', key: 'carbs' },
          { title: 'Protein (g)', key: 'protein' },
          { title: 'Iron (%)', key: 'iron' },
        ],
        desserts: [
          {
            name: 'Frozen Yogurt',
            calories: 159,
            fat: 6.0,
            carbs: 24,
            protein: 4.0,
            iron: '1%',
            gluten: false,
            group: {
             deep: 1,
            }
          },
          {
            name: 'Ice cream sandwich',
            calories: 237,
            fat: 9.0,
            carbs: 37,
            protein: 4.3,
            iron: '1%',
            gluten: false,
            group: {
             deep: 1,
            }
          },
          {
            name: 'Eclair',
            calories: 262,
            fat: 16.0,
            carbs: 23,
            protein: 6.0,
            iron: '7%',
            gluten: true,
            group: {
             deep: 2,
            }
          },
          {
            name: 'Cupcake',
            calories: 305,
            fat: 3.7,
            carbs: 67,
            protein: 4.3,
            iron: '8%',
            gluten: true,
            group: {
             deep: 2,
            }
          },
          {
            name: 'Gingerbread',
            calories: 356,
            fat: 16.0,
            carbs: 49,
            protein: 3.9,
            iron: '16%',
            gluten: true,
            group: {
             deep: 2,
            }
          },
          {
            name: 'Jelly bean',
            calories: 375,
            fat: 0.0,
            carbs: 94,
            protein: 0.0,
            iron: '0%',
            gluten: false,
            group: {
             deep: 2,
            }
          },
          {
            name: 'Lollipop',
            calories: 392,
            fat: 0.2,
            carbs: 98,
            protein: 0,
            iron: '2%',
            gluten: false,
            group: {
             deep: 3,
            }
          },
          {
            name: 'Honeycomb',
            calories: 408,
            fat: 3.2,
            carbs: 87,
            protein: 6.5,
            iron: '45%',
            gluten: true,
            group: {
             deep: 3,
            }
          },
          {
            name: 'Donut',
            calories: 452,
            fat: 25.0,
            carbs: 51,
            protein: 4.9,
            iron: '22%',
            gluten: true,
            group: {
             deep: 4,
            }
          },
          {
            name: 'KitKat',
            calories: 518,
            fat: 26.0,
            carbs: 65,
            protein: 7,
            iron: '6%',
            gluten: true,
            group: {
             deep: 4,
            }
          },
        ],
      }
    },
  }
</script>

@tongxuanbao tongxuanbao changed the title fix: using raw instead fix(VDataTable): used raw for table sorting instead of column Jun 29, 2024
@tongxuanbao tongxuanbao marked this pull request as draft June 29, 2024 04:56
@tongxuanbao tongxuanbao marked this pull request as ready for review July 2, 2024 11:35
@tongxuanbao tongxuanbao changed the title fix(VDataTable): used raw for table sorting instead of column fix(VDataTable): used a combination of raw and columns in sorting item transformation Jul 3, 2024
@cjhudson101
Copy link
Contributor

This looks good. Was hoping this fixed an issue with group by sort getting overriden by sort-by prop, but it does not.

@tongxuanbao
Copy link
Contributor Author

This looks good. Was hoping this fixed an issue with group by sort getting overriden by sort-by prop, but it does not.

Do you have a reproduce of the issue ? It might be related

@chudson-incomm
Copy link

@tongxuanbao Another PR appears to be fixing the issue I am describing. You can take a look at it if you like.

#20047

@johnleider johnleider added T: bug Functionality that does not work as intended/expected C: VDataTable VDatatable labels Jul 10, 2024
@johnleider johnleider added this to the v3.6.x milestone Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: VDataTable VDatatable T: bug Functionality that does not work as intended/expected
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug Report][3.6.10] VDataTable group is not sorted when key is not in header
4 participants