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(VData): allow group-by to be used with disable-sort #13027

Merged

Conversation

Esgator
Copy link
Contributor

@Esgator Esgator commented Jan 29, 2021

Description

fixes #11905

Motivation and Context

Currently group-by isn't working properly if disable-sort is set. The group-by algorithm needs a sorted array to work. Usually when group-by is set the array will be sorted first by the group-by criteria then by sort-by criterias.
Now we allow the array to be sorted by group-by criteria although disable-sort is set.

How Has This Been Tested?

playground

Markup:

<template>
  <v-container fluid>
    <v-data-table
      :headers="headers"
      :items="desserts"
      item-key="name"
      group-by="category"
      class="elevation-1"
      disable-sort
    ></v-data-table>
  </v-container>
</template>

<script>
export default {
  data() {
    return {
      headers: [
        {
          text: "Dessert (100g serving)",
          align: "start",
          value: "name",
          groupable: false
        },
        { text: "Category", value: "category", align: "right" },
        { text: "Dairy", value: "dairy", align: "right" }
      ],
      desserts: [
        {
          name: "Frozen Yogurt",
          category: "Ice cream",
          dairy: "Yes"
        },
        {
          name: "Ice cream sandwich",
          category: "Ice cream",
          dairy: "Yes"
        },
        {
          name: "Eclair",
          category: "Cookie",
          dairy: "Yes"
        },
        {
          name: "Cupcake",
          category: "Pastry",
          dairy: "Yes"
        },
        {
          name: "Gingerbread",
          category: "Cookie",
          dairy: "No"
        },
        {
          name: "Jelly bean",
          category: "Candy",
          dairy: "No"
        },
        {
          name: "Lollipop",
          category: "Candy",
          dairy: "No"
        },
        {
          name: "Honeycomb",
          category: "Toffee",
          dairy: "No"
        },
        {
          name: "Donut",
          category: "Pastry",
          dairy: "Yes"
        },
        {
          name: "KitKat",
          category: "Candy",
          dairy: "Yes"
        }
      ]
    };
  }
};
</script>

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Improvement/refactoring (non-breaking change that doesn't add any features but makes things better)

Checklist:

  • The PR title is no longer than 64 characters.
  • The PR is submitted to the correct branch (master for bug fixes and documentation updates, dev for new features and backwards compatible changes and next for non-backwards compatible changes).
  • My code follows the code style of this project.
  • I've added relevant changes to the documentation (applies to new features and breaking changes in core library)

@johnleider johnleider added C: VData T: bug Functionality that does not work as intended/expected labels Feb 9, 2021
@johnleider johnleider added this to the v2.4.x milestone Feb 9, 2021
@KaelWD KaelWD force-pushed the master branch 12 times, most recently from ddbea7b to c7a93f7 Compare February 19, 2021 14:19
nekosaur
nekosaur previously approved these changes Feb 20, 2021
Copy link
Member

@nekosaur nekosaur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a test for this @Esgator

@johnleider
Copy link
Member

@Esgator friendly reminder about the unit tests requested by @nekosaur

@johnleider johnleider added the S: on hold The issue is on hold until further notice label Apr 6, 2021
@KaelWD KaelWD modified the milestones: v2.4.x, v2.5.x May 11, 2021
@johnleider johnleider merged commit 560b52c into vuetifyjs:master May 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: VData S: on hold The issue is on hold until further notice 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] v-data-table doesn't correctly group-by items when disable-sort is set to true
4 participants