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(VDataIterator): emit page-count event #10652

Merged
merged 1 commit into from
Feb 25, 2020

Conversation

nekosaur
Copy link
Member

Description

we were not emitting the page-count event at all

Motivation and Context

closes #8886

How Has This Been Tested?

Markup:

<template>
  <div>
    <v-text-field label="search" v-model="search"></v-text-field>
    <v-data-iterator
      :items="desserts"
      :options.sync="options"
      :loading="loading"
      :items-per-page="pageSize"
      :page="page"
      @page-count="pageCountChanged"
      :search="search"
      hide-default-footer
    >
      <template v-slot:default="props">
        <v-row>
          <v-col cols="12" md="3" v-for="item in props.items" :key="item.name">
            <v-card role="button">
              <v-card-text class="text-center">
                <h4>{{ item.name }}</h4>
              </v-card-text>
            </v-card>
          </v-col>
        </v-row>
      </template>
    </v-data-iterator>
    <v-pagination v-model="page" :length="pageCount"></v-pagination>
  </div>
</template>

<script>
  export default {
    data () {
      return {
        search: '',
        totalDesserts: 0,
        pageCount: 0,
        page: 1,
        pageSize: 4,
        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%',
          },
        ],
        loading: true,
        options: {},
        headers: [
          {
            text: 'Dessert (100g serving)',
            align: 'left',
            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' },
        ],
      }
    },
    methods: {
      pageCountChanged (v) {
        this.pageCount = v
      },
    },
  }
</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)

@nekosaur nekosaur added the C: VDataIterator VDataiterator label Feb 23, 2020
@nekosaur nekosaur added this to the v2.2.x milestone Feb 23, 2020
@nekosaur nekosaur self-assigned this Feb 23, 2020
@johnleider johnleider merged commit 4d04771 into master Feb 25, 2020
whoistobias pushed a commit to whoistobias/vuetify that referenced this pull request Feb 26, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Mar 27, 2020
@nekosaur nekosaur deleted the fix/8886-data-iterator-page-count branch August 3, 2020 13:21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
C: VDataIterator VDataiterator
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug Report] page-count event of v-data-iterator did not triggered when using loading data from server side.
2 participants