"Enhance your Ag-grid react app with custom cell skeleton loaders

I'm currently attempting to incorporate a skeleton loader into ag grid within my react application, resembling the following design. However, I am uncertain about its feasibility.

https://i.sstatic.net/5Kxzu.png

Various attempts have been made using overlayTemplate and loadingCellRenderer, but unfortunately, I have not succeeded in making it functional. Has anyone encountered a similar situation previously?

Answer №1

If you're utilizing server-side rendering with the rowModelType: "serverSide" option, you have the ability to customize the loadingCellRenderer. By leveraging the

gridOptions.columnApi.getColumnState()
method provided in the parameters, you can ensure that the width of each grey oval corresponds to the width of each column.

class EnhancedLoadingCellRenderer {
    init(params) {
        let container = document.createElement('div');
        container.style.height = "100%";
        container.style.width = "100%";

        /* Adjust padding or border-radius according to your requirements */
        for(let column of params.columnApi.getColumnState()){
            if(column.hide){
                continue;
            }
            let cell = document.createElement('div');
            cell.style.display = "inline-block";
            cell.style.width = column.width + 'px';
            cell.style.height = "100%";
            cell.style.padding = '15px';
            let oval = document.createElement('div');
            oval.style.backgroundColor = 'lightgray'
            oval.style.borderStyle = 'none'
            oval.style.height = "100%";
            oval.style.width = "100%";
            oval.style.borderRadius = '10px'
            cell.appendChild(oval);
            container.appendChild(cell);
        }

        this.container = container;
    }

    getGui() {
        // Return the same container for each row
        return this.container;
    }
}

const advancedGridOptions = {
    loadingCellRenderer: EnhancedLoadingCellRenderer,
    loadingCellRendererParams: {},
    rowModelType: "serverSide",
    serverSideDatasource: datasource,
}

https://example.com/image.png

For client-side rendering, it may not be practical to implement an overlay Loading Template in the same manner because rows are not generated individually. However, you could still utilize a custom renderer for overlayLoadingTemplate, where the loadingCells fill the entire grid.

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

Require guidance and resolution

<div class="container"> <div class="top-section"> <img id="image1" /> <img id="image2" /> </div> <div class="content"> ... </div> <div class="bottom-section"> ... </div> </div ...

Create an instance of an object in order to make it accessible to several directives

My Current Project: I am currently working on developing two attribute directives. One directive is designed to move an element to the left, while the other centers an element on the page. Below is a snippet of the code showcasing how I am using ng-style t ...

Ways to remove the line under a logo in HTML using CSS and Bootstrap

While working on a website design, I encountered an issue with the logo where it has a line of the background color under it. This is frustrating and affects the overall design. Does anyone have a straightforward solution to remove this line? I need someth ...

Why doesn't the background color display properly when the div height is set to auto?

When I set the height of #container to auto, the background-color does not display. However, when I set it to a fixed height like 1000px, it shows up. I've attempted using "overflow:auto", but that did not solve the issue. How can I fix this? I want # ...

Implement a tooltip feature that appears when hovering over a specific class within a span tag

In my TS file I have an HTML string that I am displaying in my HTML file. Within the text, there are span tags with a class called "highlight." I would like to create a tooltip that appears when hovering over this highlight class. The string/text is store ...

The styled horizontal list item has a background color that is not covering the entire

After setting up my CSS, I noticed a discrepancy in how the background color behaves when hovering over links in the navigation versus links in the footer. While the entire "button" area is filled with the background color in the nav, only the space behind ...

After submitting the form, React checkboxes fail to reset their state

Being a relative newcomer to React, I embarked on creating a skincare app as a project to enhance my understanding. In designing the app, I incorporated a form for product registration which includes checkboxes. My current dilemma revolves around clearing ...

Attempting to align several div elements in the middle while ensuring they all stay in a single row

I've been attempting to center a contact form and a feedback form side by side. I tried using float: left; for both to align them horizontally, but I also want them to be centered on the page. Whenever I manage to display them together horizontally, ...

Tips on handling parameters in the form of a single value or an array of values

I've implemented multiple functions structured like this: this.something = function (which) { // Can be one or many. if (!Array.isArray(which)) { // Single input case. doSomething(which); } else { ...

Transfer a file to an AWS S3 bucket by providing the absolute file path

My goal is to successfully upload files from Express ejs to an AWS S3 bucket. I have been able to achieve this, but I encounter an issue when trying to select files from a directory or folder that is different from where my index.js file is located. The er ...

What impact does adding 'ng' in unit tests have on how promises are handled?

Here is an example of a service that utilizes $q.when to wrap a promise from a third-party library: // myService.js angular.module('myApp', []) .service('myService', function($q, $window) { var api = new $window.MyAPI(); this ...

How can I modify the font color of a TextField in Material UI?

I'm currently utilizing Material UI framework for my project. However, I've encountered difficulties while attempting to modify the font color of the multiline TextField. <TextField className = "textfield" fullWidth ...

Managing user access and permissions using JavaScript on the front end

I find myself in a situation where I am working on developing a single page application: The majority of the operations rely on ajax requests. Depending on the user's login status (admin, regular user, visitor), different components need to be displ ...

Struggling to halt the continuous motion

Trying to create a typewriting effect using HTML5 has been quite the challenge. To bring it all together, I've turned to the pixi.js plugin. While I have managed to get it partly working, it appears that the update() method responsible for updating t ...

Rails application experiencing issues with AJAX loading without requiring a page refresh

I implemented an AJAX script within my Rails application to dynamically add a new car object to the feed without refreshing the page. Currently, even though the car is successfully being posted in the background, I still need to manually refresh the webpag ...

Unable to create selected buttons in Vue.js

I'm having trouble creating buttons that can select all options when clicking on either size or color. The buttons aren't showing up at all. Can someone help me identify the issue? I've attempted various solutions but none seem to work. Any ...

Retrieving and showing items based on the user's ID in MongoDB

I am attempting to retrieve and display all entries in the 'item' collection that belong to a specific user/userID from the user collection. item_controller.js: const Item = require('../models/item_schema') const getUserItems = (req, ...

Tips for retrieving the identifier of a row in a mui datagrid when an onClick event occurs

I'm attempting to integrate a material-ui datagrid with a sql database for the purpose of enabling edits to be made via a form rather than editing individual rows and cells one by one. My goal is to pass the row's id as a parameter to a function ...

Managing CSS background images for various screen aspect ratios, from 16:9 to 9:16

Currently, I have a webpage that utilizes a background image set up like this: body { background-image : url("https://example.com/image.png"); background-size : cover; background-repeat : no-repeat; } While this s ...

Looking to boost the number of recent posts on your Gatsby starter blog's homepage from 3 to 20?

I have recently begun using the Gatsby Minimal Starter Blog by LekoArts from here and also checked out the corresponding Github repository. Currently, only the 3 latest posts are displayed on the homepage. Is there a way to increase this number to 30? I ...