how to create this ag-grid loading overlay

Viewed 2365

I've seen an example for a loading overlay for a react ag grid here:

https://www.ag-grid.com/documentation/react/overlays/#example

When pressing the "Show loading overlay" button, I'm not sure how to call that effect that it kinda adds a transparent white screen and some words above it.

From the code we can see that the component itself is simply:

'<span className="ag-overlay-loading-center">Please wait while your rows are loading</span>'

I'm guessing that the transparent white screen in the background is caused due to that "ag-overlay-loading-center" css class, but I don't know where it comes from exactly..

How can I create that effect like in the example?

1 Answers

First, the overlay code should not have className in it, as it is a plain HTML <span> tag. so that might not be setting the classes right thus, not showing the overlay.

But, I had the same issue with the loader being quite bad and not informative. Luckily I can change it using the following CSS class (that i stole form semanticUI):


.loadingx:before {
  position: absolute;
  content: '';
  top: 0%;
  left: 0%;
  background: rgba(255, 255, 255, 0.8);
  width: 100%;
  height: 100%;
  border-radius: 0.28571429rem;
  z-index: 100;
}

.loadingx:after {
  position: absolute;
  content: '';
  top: 50%;
  left: 50%;
  margin: -1.5em 0em 0em -1.5em;
  width: 3em;
  height: 3em;
  -webkit-animation: segment-spin 0.6s linear;
  animation: segment-spin 0.6s linear;
  -webkit-animation-iteration-count: infinite;
  animation-iteration-count: infinite;
  border-radius: 500rem;
  border-color: #223088 rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1);
  border-style: solid;
  border-width: 0.2em;
  box-shadow: 0px 0px 0px 1px transparent;
  visibility: visible;
  z-index: 101;
}

@-webkit-keyframes segment-spin {
  from {
    -webkit-transform: rotate(0deg);
    transform: rotate(0deg);
  }

  to {
    -webkit-transform: rotate(360deg);
    transform: rotate(360deg);
  }
}

@keyframes segment-spin {
  from {
    -webkit-transform: rotate(0deg);
    transform: rotate(0deg);
  }

  to {
    -webkit-transform: rotate(360deg);
    transform: rotate(360deg);
  }
}

EDIT: here is literally how I am using it :

overlayLoadingTemplate:
      '<div class="loadingx" style="margin: 7em"></div> <span class="ag-overlay-loading-center " style="font-size: 18px; z-index: 100000"> Loading Rows ...</span>',

the "Loading Rows ..." text doesn't actually show at all, you can remove it.

for showing the overLay using the API : gridApi.showLoadingOverlay() for hiding it : gridApi.hideOverlay()

adding this class to the loader span (with class="loadingx") would instantly show a grey overlay and a circular loader in the middle.

hope this works.

Related