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): native event as argument to click:row #15864

Merged

Conversation

ricardovanlaarhoven
Copy link
Contributor

@ricardovanlaarhoven ricardovanlaarhoven commented Oct 11, 2022

Description

You are not able to do something with the event argument when using the row click. One thing that could be possible after this PR is creating a ctrl+click for a new tab.
There is an @TODO for implementing this in v3 as first argument but for making the migration easier it could be possible after this PR

How Has This Been Tested?

<template>
  <v-app id="inspire">
    <v-container>

      <v-data-table
        :headers="headers"
        :items="desserts"
        :items-per-page="5"
        class="elevation-1"
        @click:row="showDetails"
      ></v-data-table>
    </v-container>
  </v-app>
</template>

<script>
  export default {
    data () {
      return {
        headers: [
          {
            text: 'Dessert (100g serving)',
            align: 'start',
            sortable: false,
            value: 'name',
          },
          { text: 'Calories', value: 'calories' },
          { text: 'Fat (g)', value: 'fat' },
          { text: 'Carbs (g)', value: 'carbs' },
          { text: 'Protein (g)', value: 'protein' },
          { text: 'Iron (%)', value: 'iron' },
        ],
        desserts: [
          {
            name: 'Frozen Yogurt',
            calories: 159,
            fat: 6.0,
            carbs: 24,
            protein: 4.0,
            iron: '1%',
          },
          {
            name: 'Ice cream sandwich',
            calories: 237,
            fat: 9.0,
            carbs: 37,
            protein: 4.3,
            iron: '1%',
          },
          {
            name: 'Eclair',
            calories: 262,
            fat: 16.0,
            carbs: 23,
            protein: 6.0,
            iron: '7%',
          },
          {
            name: 'Cupcake',
            calories: 305,
            fat: 3.7,
            carbs: 67,
            protein: 4.3,
            iron: '8%',
          },
          {
            name: 'Gingerbread',
            calories: 356,
            fat: 16.0,
            carbs: 49,
            protein: 3.9,
            iron: '16%',
          },
          {
            name: 'Jelly bean',
            calories: 375,
            fat: 0.0,
            carbs: 94,
            protein: 0.0,
            iron: '0%',
          },
          {
            name: 'Lollipop',
            calories: 392,
            fat: 0.2,
            carbs: 98,
            protein: 0,
            iron: '2%',
          },
          {
            name: 'Honeycomb',
            calories: 408,
            fat: 3.2,
            carbs: 87,
            protein: 6.5,
            iron: '45%',
          },
          {
            name: 'Donut',
            calories: 452,
            fat: 25.0,
            carbs: 51,
            protein: 4.9,
            iron: '22%',
          },
          {
            name: 'KitKat',
            calories: 518,
            fat: 26.0,
            carbs: 65,
            protein: 7,
            iron: '6%',
          },
        ],
      }
    },
    methods: {
      showDetails (item, data, event) {
        console.log(item, '-', data, '-', event)
      },
    },
  }
</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)

@ricardovanlaarhoven
Copy link
Contributor Author

I'm sorry i branched of master since i tought this was such a small change without impact. But it's a feature so it should be dev i guess. Is that an issue?

@KaelWD KaelWD changed the base branch from dev to master October 11, 2022 06:59
@KaelWD KaelWD changed the title feat(VDataTable): Added event as argument to row:click fix(VDataTable): add event as argument to click:row Oct 11, 2022
@KaelWD KaelWD added T: bug Functionality that does not work as intended/expected C: VDataTable VDatatable labels Dec 12, 2022
@KaelWD KaelWD added this to the v2.6.x milestone Dec 12, 2022
@KaelWD KaelWD changed the title fix(VDataTable): add event as argument to click:row fix(VDataTable): native event as argument to click:row Dec 12, 2022
@KaelWD KaelWD merged commit 17dd133 into vuetifyjs:master Dec 12, 2022
@ricardovanlaarhoven ricardovanlaarhoven deleted the add-event-to-datatable-row-click branch December 13, 2022 10:53
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.

None yet

2 participants