Display spinner until List Items are loaded

2 Mar 20223 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.

        target: document.getElementById('spinner')

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

<!-- ListView element -->
@Html.EJS().ListView("element").DataSource(dataManger =>
}).Query("new ej.data.Query().from('Products').select('ProductID,ProductName').take(10)").ActionBegin("onBegin").Fields(new ListViewFieldSettings { Id = "ProductID", Text = "ProductName" }).ShowHeader(true).HeaderTitle("Product Name").Width("300").ActionComplete("oncomplete").Render()

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.

@using Syncfusion.EJ2
@using Syncfusion.EJ2.Lists;

<ejs-listview enable="true" id="remotelist" headerTitle="Products" showHeader="true" query="new ej.data.Query().from('Products').select('ProductID,ProductName').take(10)">
    <e-data-manager url="//js.syncfusion.com/demos/ejServices/Wcf/Northwind.svc/" crossDomain="true">
    <e-listview-fieldsettings id="ProductID" text="ProductName">

    #element {
        display: block;
        max-width: 350px;
        min-height: 200px;
        margin: auto;
        border: 1px solid #dddddd;
        border-radius: 3px;
    function oncomplete() {
        document.getElementById('spinner').style.display = "none";
    function onBegin() {
        var ele = document.createElement('div');
        ele.id = 'spinner';
            target: document.getElementById('spinner')
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;

namespace WebApplication1.Controllers
    public class ListViewController : Controller
        public IActionResult list()
            return View();