'Vuetify rendering v-datatable automatically

I have a problem v-datatable rendering each time I change a v-select.

I´d like it render only when I click in a button, I created to do fetch data from server.

Here is the codepen: https://codepen.io/luizalves/pen/VwrwXwE?editors=101

For now, it´s rendering all times I change the v-select.

data:()=>({
grupos: [
      { id: 1, nome: 'Diário', ffi: 'YYYY-MM-DD', fff: 'DD-MM-YYYY' },
      { id: 2, nome: 'Mensal', ffi: 'YYYY-MM', fff: 'MM-YYYY' },
      { id: 3, nome: 'Anual', ffi: 'YYYY', fff: 'YYYY' },
    ],
grupo:1
headers: [
      { text: 'Data', value: 'label', sortable: false },
      { text: 'Total(R$) ', value: 'total', sortable: false },
    ],
)}

// data-table

        <v-select
              v-model="grupo"
              label="Grupado por"
              :items="grupos"
              item-text="nome"
              item-value="id"
              class="purple-input"
            />
 <v-btn
        class="mt-1 mr-3"
        color="info"
        @click.stop="getEstatisticasPeriodo()"
      >
        Pesquisar
      </v-btn>
    <v-data-table
                  :headers="headers"
                  :items="result_dados"
                  :items-per-page="3"
                  :footer-props="{
                    'items-per-page-options': [3, 5, 10, 20, 30, 40, 50],
                  }"
                  class="elevation-1"
                >
                  <template
                    v-for="(header, i) in headers"
                    #[`item.${header.value}`]="{ item }"
                  >
                    <template v-if="header.value !== 'actions'">
                      <span :key="i">
                        {{ formatColumn(item, header) }}
                      </span>
                    </template>
                  </template>
         </v-data-table>
 methods: {
    formatColumn(item, col) {
      if (!item[col.value]) return ''
      if (['total'].includes(col.value)) {
        const formatado = Number(item[col.value]).toLocaleString('pt-BR', {
          style: 'currency',
          currency: 'BRL',
        })
        return formatado
      }
      if (['label'].includes(col.value)) {
        const ffi = this.grupos.find((m) => m.id == this.grupo).ffi
        const fff = this.grupos.find((m) => m.id == this.grupo).fff
        return this.$moment(item[col.value], ffi).format(fff)
      } else return item[col.value]
    },
getEstatisticasPeriodo(){
        // fetch api data
}
....


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source