Philip
Philip

Reputation: 13

How to create a "Loading" pop up in google sheets?

I'm using the 'importrange' function in a 2 way setup between 2 sheets to hide proprietary formulas which takes a few seconds to update results to the current sheet. What I would like to do is have a "Please wait while loading..." box pop up for X amount of seconds when user information in input cell. I've seen some examples for pop ups but not sure how to do it when a cell is updated.... Any ideas?

Upvotes: 1

Views: 4757

Answers (2)

Juan Diego Antezana
Juan Diego Antezana

Reputation: 912

You can also use toasts in spreadsheets:

Spreadsheet Toast

 // Show a 3-second popup with the title "Status" and the message "Task started".
 SpreadsheetApp.getActiveSpreadsheet().toast('Task started', 'Status', 3);

Upvotes: 4

Cooper
Cooper

Reputation: 64100

This uses the javascript timer. It will display a modeless dialog for 5 seconds and the go away. Of course you can put whatever animation on there that you like. And I included the dispStatus function which I use almost all of the time. It's probably not the fanciest way to do it. But it works.

 function timer_test()
{
dispStatus('Loading.....','<script>var myVar = setInterval(myTimer ,5000);function myTimer() { google.script.host.close();}</script>',200,200)
}

function dispStatus(title,html,width,height)
{
// Display a modeless dialog box with custom HtmlService content.
  var title = typeof(title) !== 'undefined' ? title : 'No Title Provided';
  var width = typeof(width) !== 'undefined' ? width : 250;
  var height = typeof(height) !== 'undefined' ? height : 300;
  var html = typeof(html) !== 'undefined' ? html : '<p>No html provided.</p>';
  var htmlOutput = HtmlService
     .createHtmlOutput(html)
     .setWidth(width)
     .setHeight(height);
 SpreadsheetApp.getUi().showModelessDialog(htmlOutput, title);
} 

Upvotes: 2

Related Questions