Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

152
Views
no-data section loads first and then shows the data in v-data-table

I am using vuetify v-data-table to display data. The issue I am facing here is No Settings Yet message always shows for like 1 second and then displays the data. Its like no data message loads first and then the actual data shows up. Is there a way to fix this.

<template>
  <div>
          <v-card>
              <v-data-table
                :headers="headers"
                :items="settings"
                hide-default-footer
                disable-pagination
                :mobile-breakpoint="0">

                <template slot="top" v-if="isLoading">
                  <v-progress-linear
                      indeterminate
                      color="red"
                  ></v-progress-linear>
                </template>

                <template slot="item" slot-scope="props">
                  <tr>
                    <td>{{ props.item.name }}</td>
                    <td>{{ props.item.value }}</td>
                </tr>
              </template>
              <template slot="no-data" >
                <v-alert id='no-data' :value="true" color="error" icon="warning">
                  No Settings Yet
                </v-alert>
              </template>
            </v-data-table>
          </v-card>
  </div>
</template>

<script>

  export default {
    data: function() {
      return {
        settings: [],
        headers: [
          { text: 'Name', value: 'name'},
          { text: 'Value', value: 'value'},
          { text: 'Actions', sortable: false}
        ],
        isLoading: false
      }
    },
    created() {
      this.fetchSettings();
    },
    
    methods: {
      fetchSettings() {
        var that = this;

        that.isLoading = true;
        this.$axios.get('/settings.json')
        .then(response => {
          that.settings = response.data;
          that.isLoading = false;
        });
      }
    }
  }
</script>
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

From the v-data-table's point of view in your case there are only 2 states: data is present or not (yet). That's why no-data slot is always visible on loading.

If you want to show both "Loading" message and "No settings yet" alert in this slot, you can do it this way:

<v-data-table
  :headers="headers"
  :items="desserts"
  :search="search"
  hide-default-footer
  disable-pagination
  :mobile-breakpoint="0"
>
  <template #top>
    <v-progress-linear
      v-show="isLoading"
      indeterminate
      color="red"
    />
  </template>
  <template #no-data>
    <v-alert v-show="!isLoading" :value="true" color="error" icon="warning">
      No Settings Yet
    </v-alert>
    <span v-show="isLoading">Loading...</span>
  </template>
</v-data-table>

Check this CodePen playground for a better understanding. There you'll also be able to understand the difference between no-data and no-results slots.

about 4 years ago · Juan Pablo Isaza Report

0

I think you can do this by adding v-if directive in no-data slot like below example

            <template slot="no-data" v-if="!isLoading">
            <v-alert id='no-data' :value="true" color="error" 
               icon="warning">
              No Settings Yet
            </v-alert>
          </template>
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!