2017-02-20 32 views
0

我在兩張表單之間使用「導入區域」功能以2種方式設置隱藏專有公式,這需要幾秒鐘的時間才能將結果更新到當前表單。我想要做的是在輸入單元格中輸入用戶信息時,彈出「正在加載...請稍候...」框,並等待X秒。我已經看到了一些彈出窗口的例子,但不知道如何更新單元格時如何去做....任何想法?如何在谷歌表格中創建「加載」彈出窗口?

回答

1

這使用JavaScript計時器。它將顯示5秒鐘的無模式對話並消失。當然,你可以把你喜歡的任何動畫放在那裏。而且我包括幾乎所有時間都使用的dispStatus函數。這可能不是最好的方式。但它的工作。

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); 
} 
+0

你們是真棒謝謝! – Philip

2

您還可以使用敬酒電子表格:

Spreadsheet Toast

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

感謝這個例子! – Philip

+0

好主意。我忘了吐司。感謝提醒。 – Cooper