2012-07-10 36 views

回答

4

在HtmlService中這很容易,在UiApp中有點難度,儘管可行。下面是一個HtmlService例如:

代碼文件命名爲 'UI'

function getGroup(group) { 
    return GroupsApp.getGroupByEmail(group).getUsers().map(
    function(user){return user.getEmail(); }); 
} 

function doGet() { 
    return HtmlService.createHtmlOutputFromFile("ui"); 
} 

HTML文件

<html> 
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.js"></script> 
    <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js"></script> 
    <script> 
    function refresh() { 
     google.script.run.withSuccessHandler(function(tags) {$("#tags").autocomplete({source: tags});}) 
     .getGroup(document.getElementById('group').value); 
    } 
    </script> 

    Enter a group name in the first box. The second box will autocomplete 
    group members using GroupApp. 
    <br> 
    <label for="group">Group: </label> 
    <input id="group" onchange='refresh()'> 
    <div class="ui-widget"> 
    <label for="tags">Members: </label> 
    <input id="tags"> 
    </div> 
</html> 
+0

感謝 - 在UiApp中尋找它... – BruceM 2012-07-10 18:43:30

+1

感謝@CoreyG任何想法爲什麼你的代碼不適合我 - 在Linux上使用Chrome? - 我很高興當發現這個職位 – 2013-05-31 21:35:07

1

[編輯] HtmlService已更快,更先進。 UiApp有效,但由於網絡而緩慢。

HtmlService這裏的解決方案Populate jQuery autocomplete list using value array from Google Spreadsheet好多了。

一個了UiApp版本:https://sites.google.com/site/scriptsexamples/learn-by-example/uiapp-examples-code-snippets/suggest-box

還是這樣,我建:

要看到它在行動中,鍵入機場名稱爲: http://www.treesforlife.org.au/carbon-calculator

但是這是與完成電子表格公式,而不是谷歌應用程序腳本。請參閱http://www.cellmaster.com.au

+0

斷開鏈接..https://productforums.google.com/d/topic/apps-script/BzvEGbMeSt0/discussion – 2013-11-07 00:19:13

+1

(編輯)刪除斷開的鏈接 - 添加兩個新的鏈接,以更好地解決方案 – eddyparkinson 2013-12-23 10:20:23

相關問題