How can a loading indicator be displayed while retrieving data from the database using a prop in a tabulator?

Incorporating a tabulator component into my vue app, I have set up the Tabulator options data and columns to be passed via props like this:

// parent component
<template>
    <div>
        <Tabulator :table-data="materialsData" :table-columns="options.columns" :is-loading="materials.isLoading" />
    </div>
</template>

...
// Tabulator component
props: {
    tableData: {
        type: Array,
        default: function() {
            return [
                { name: "Billy Bob", age: "12" },
                { name: "Mary May", age: "1" },
            ];
        },
    },
    tableColumns: {
        type: Array,
        default: function() {
            return [
                { title: "Name", field: "name", sorter: "string", width: 200, editor: true },
                { title: "Age", field: "age", sorter: "number", align: "right", formatter: "progress" },
            ];
        },
    },
    isLoading: {
        type: Boolean,
        default: true,
    },
},
mounted() {
    // instantiate Tabulator
    this.tabulator = new Tabulator(this.$refs.table, {
        placeholder: "loading data...",
        //placeholder: "<font-awesome-icon icon='circle-notch' spin size='2x' />",
        data: this.tableData, // link data to table (passed as prop)
        columns: this.tableColumns, // define table columns (passed as prop)
    });
},

The functionality is smooth except for indicating to the user that data is in the process of loading. Trying out the placeholder option () initially seemed promising, but it proved unsuitable as it gets rendered even when no data is present.

Is there a way to instruct Tabulator to display a loading spinner or text based on the prop isLoading?

Answer №1

Tabulator comes equipped with a loading overlay feature for when it retrieves data through ajax, and you have the option to personalize this feature using the ajaxLoaderLoading parameter.

var table = new Tabulator("#table", {
    ajaxLoaderLoading:"<span>Loading Data</span>",
});

If you need to load your data externally outside of Tabulator and then import it using the setData command, this functionality is not directly supported by Tabulator.

A possible solution would be to position an element over Tabulator that appears when you initiate your database load operation.

Answer №2

In the latest version of tabulator, Tabulator 5, there is a new option introduced called dataLoaderLoading. The documentation specifies that you can pass an 'html' as part of this option. However, I encountered a bug where passing a string did not generate the html correctly (possibly due to how the Template element was utilized). To resolve this issue, I found that passing an html element directly worked as follows:

const template = document.createElement('template');
template.innerHTML = '<div style="display:inline-block;" class="d-flex flex-row">' +
                    '<div>Loading... </div>' +
                    '<div class="ml-2 activity-sm" data-role="activity" data-type="atom" data-style="dark"></div>' +
                '</div>';
const dataLoaderLoading = template.content.firstChild;
...
new Tabulator("#mytable", {
    dataLoaderLoading: dataLoaderLoading,
    ...

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

This function is designed to only work under specific conditions

Looking for assistance with a function that takes an item ID as input and changes its border when pressed. The goal is to increase the border width by 2px when there is no border, and remove the border completely when pressed again. Currently, only the f ...

Ensure that this specific attribute remains responsive by either setting it within the data option or initializing it for class-based components. Vuex is another viable option to consider for managing state

Terminal Error in vue.runtime.esm.js:4573 [Vue warn]: The property or method "setRegisterEmail" is not defined in the instance but referenced during rendering. Please ensure that this property is reactive, either in the data option, o ...

How to apply multiple filters in JavaScript?

I have a set of objects that require filtering. If the object has an active status of true, it should always be included in the filtered result regardless of other conditions. If there is text entered for search, then the remaining items should be filter ...

What do you believe to be superior: Vue UI design?

Scenario: Application managing multiple user roles. A view with extensive conditional rendering in the template. a) Is it preferable to have numerous conditional statements in a single view's template? b) Should separate views be created for each ro ...

Error: React JS is unable to access the property 'path' because it is undefined

Currently, I am encountering an issue while setting the src of my image in React to this.props.file[0].path. The problem arises because this state has not been set yet, resulting in a TypeError: Cannot read property 'path' of undefined. To provid ...

Understanding the sequence of operations in Javascript using setTimeout()

If I have the following code: function testA { setTimeout('testB()', 1000); doLong(); } function testB { doSomething(); } function doLong() { //takes a few seconds to do something } When I run testA(), what happens after 1000 mill ...

Sending data over a network using Socket and node.js

Trying to update a location on a Google Map using socket.io and node.js. I have 2 different methods for updating the map. There may be some basic issue as I am new to this. 1) Method using an API call that works: app.post('/location', function( ...

Select the first item that is visible and chosen

Currently, I am working with a select list: <option ng-repeat="hour in Hours" value="{{hour.Value}}" ng-show="filterEvent($index)" ng-selected="hour.Value == EventDate || $first"> {{hour.Text}} </opti ...

Changing an array into an object in JavaScript without rearranging the keys

I have a collection { 1: {id: 1, first: 1, last: 5} 2: {id: 2, first: 6, last: 10} 3: {id: 3, first: 11, last: 15} } My goal is to reverse the order of items without rearranging the keys so that it looks like this: { 1: {id: 3, first: 11, last: 15} 2: { ...

Error: Attempting to access a property 'notesObjectInService' that is undefined on the object

I'm currently facing an issue where my controller is unable to load an object from a service called notesFactory. The console.log(typeof notesFactory) statement returns 'undefined', causing notesObjectInService to trigger an exception. Desp ...

Struggling to implement a vertical scroll bar in HTML code?

<body ng-app="myApp" ng-controller="myCtrl"> <div ng-show = "dataFromRest" ng-repeat = "x in dataFromRest.posts" > <div class="tittle" style="width: 25%;"> <a href="" ng-click="showDi ...

Enhancing Kendo Grid with Checkbox Columns

I am facing a situation with my kendo grid where I need to insert two checkbox columns in addition to the existing set of columns. <script id="sectionPage" type="text/kendo-tmpl"> @(Html.Kendo().Grid<SectionPageModel>() .Na ...

Implementing a JQuery modal with backend coding

I have encountered a problem in my ASP.NET code-behind where I am trying to incorporate a modal popup. Despite my efforts, I have not been able to successfully implement it. Do you have any suggestions on how I should proceed with this process? <scrip ...

Is there a more effective method to return a response apart from using a redundant function?

function unnecessaryFunction(){ let details: SignInDetails = { user: user, account: account, company: company }; return details; } I am being told that the details value is unnecessary. Is there ...

Should front-end and back-end share Typescript data modeling through classes or interfaces?

I'm currently exploring the best approach to share the same data types between the client (React) and the server (Express + Socket.IO). Within my game, there are various rooms each storing the current status, such as: class GameRoom { players: P ...

Using ajax to submit a request to the controller

I'm currently developing an ASP.NET Core MVC application and have a registration page set up. My goal is to return View with errors if the model state is false: @model WebApplication2PROP.Entities.UserRegister @* For more information on enabling M ...

Fetching Data Using Cross-Domain Ajax Request

Seeking assistance with a cross-domain Get request via Ajax. The code for my ajax request is as follows: var currency_path = "http://forex.cbm.gov.mm/api/latest"; $.ajax({ url: currency_path, crossDomain:true, type:"GET", dataTyp ...

The React application is experiencing difficulty in rendering SVG images exclusively on Windows operating systems

My react app runs smoothly on OSX, but encounters issues on Windows due to SVG files: Module parse failed: Unexpected token (2:0) You may need an appropriate loader to handle this file type. <svg xmlns="http://www.w3.org/2000/svg" viewBox="..."> I ...

Displaying HTML content using Typescript

As a newcomer to typescript, I have a question regarding displaying HTML using typescript. Below is the HTML code snippet: <div itemprop="copy-paste-block"> <ul> <li><span style="font-size:11pt;"><span style="font-family ...

Use Javascript's JQuery library to apply functionality to a newly inserted and cloned

I am facing an issue while trying to implement JQueryUI's DatePicker on a node. It works perfectly fine for all the existing nodes, but when I use the clone function to add new nodes, it doesn't seem to apply as expected. Here is the function th ...