Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

405
Vistas
Is it possible to programmatically hide Vuetify data-table items?

I'm wondering if there is a way to hide a whole row/item in a vuetify data-table. I've read threads about hiding columns but not data-table items.

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

As per my understanding, You want to hide the specific rows from the <v-data-table>. If Yes, you can achieve that by using v-slot and manipulate the template.

Demo :

new Vue({
  el: '#app',
  vuetify: new Vuetify(),
  data () {
    return {
      headers: [
        {
          text: 'Dessert',
          value: 'name'
        }
      ],
      items: [
        {
          name: 'Frozen Yogurt',
          show: true
        },
        {
          name: 'Ice cream sandwich',
          show: false
        },
        {
          name: 'Eclair',
          show: true
        },
        {
          name: 'Cupcake',
          show: false
        }
      ]
    }
  },
})
<script src="https://unpkg.com/vue@2.x/dist/vue.js"></script>
<script src="https://unpkg.com/vuetify@2.6.6/dist/vuetify.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/vuetify@2.6.6/dist/vuetify.min.css"/>
<link rel="stylesheet" href="https://unpkg.com/@mdi/font@6.x/css/materialdesignicons.min.css"/>
<div id="app">
  <v-app id="inspire">
    <v-data-table
      :headers="headers"
      :items="items"
      class="elevation-1"
    >
      <template v-slot:item="props">
    <template v-if="props.item.show">
      <tr>{{ props.item.name }}</tr>
    </template>
</template>
    </v-data-table>
  </v-app>
</div>

about 4 years ago · Juan Pablo Isaza Denunciar

0

I think passing an empty array to your :items would fix your problem. or you can do this one :items="defaultVales || desserts".

about 4 years ago · Juan Pablo Isaza Denunciar

0

In my opinion, the best way to handle this is to add a show property to your objects and use a computed property to hide and show items

Working example

Here it will hide column on click

new Vue({
  el: '#app',
  vuetify: new Vuetify(),
  computed:{
    showItems(){
      return this.desserts.filter(x => x.show)
    }
  },
  data() {
    return {
      headers: [
        { text: 'Name', value: 'name' },
        { text: 'Score', value: 'score' },
      ],
      desserts: [{
          name: "Frozen",
          score: 66,
          show: true,
        },
        {
          name: "Tom",
          score: 100,
          show: true,
        },
        {
          name: "Eclair",
          score: 100,
          show: true,
        },
        {
          name: "Frozen",
          score: 89,
          show: true,
        },
      ]
    }
  },
  
  methods: {
    hideColumn(col){
      col.show = false
    }
  }
})
<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/vuetify@2.3.4/dist/vuetify.min.css'>
<script src='https://cdn.jsdelivr.net/npm/vue@2.x/dist/vue.js'></script>
<script src='https://cdn.jsdelivr.net/npm/vuetify@2.3.4/dist/vuetify.min.js'></script>

<div id="app">
  <v-data-table
    :items="showItems"
    :headers="headers"
    @click:row="hideColumn"
  >
  
  </v-data-table>
</div>

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda