Search results

Display spinner until list items are loaded in Vue ListView component

30 Mar 2021 / 2 minutes to read

The features of the ListView component such as remote data-binding take more time to fetch data from corresponding dataSource/remote URL. In this case, you can use EJ2 Spinner to enhance the appearance of the UI. This section explains how to load a spinner component to groom the appearance.

Refer to the following code sample to render the spinner component.

Copied to clipboard
        target: this.spinnerEle.nativeElement

Here, the data is fetched from Northwind Service URL; it takes a few seconds to load the data. To enhance the UI, the spinner component has been rendered initially. After the data is loaded from remote URL, the spinner component will be hidden in ListView actionComplete event.

Copied to clipboard
 <div class="control-section">
    <div id="flat-list">
    <!-- ListView element -->
    <ejs-listview id='sample-list' :dataSource='data' :query='query' :fields='fields' :headerTitle='headerTitle' showHeader='true' :actionComplete='onComplete'></ejs-listview>
    <div ref='spinnerEle' id="spinner" ></div>
#sample-list {
    border: 1px solid #dddddd;
    border-radius: 3px;
    margin: auto;
#flat-list {
    width: 50%;
    padding: 10px;
    margin: auto;
import Vue from "vue";
import { ListViewPlugin } from "@syncfusion/ej2-vue-lists";
import { DataManager, Query } from '@syncfusion/ej2-data';
import { createSpinner, showSpinner, setSpinner } from '@syncfusion/ej2-vue-popups';

export default {
  data: function() {
     return {
      data: new DataManager({
        url: '//',
        crossDomain: true
      query: new Query().from('Products').select('ProductID,ProductName').take(10),
      fields:  { id: 'ProductID', text: 'ProductName' },
      headerTitle: 'Products',
  mounted: function(){
     createSpinner({ target: this.$refs.spinnerEle });
  methods: {
    onComplete: function(){
      this.$ = "none";