我想要一个列表框或类似的列表框,用户可以在其中开始输入,列表框会根据已经输入的内容缩小选择范围,并在达到唯一选项后自动完成
最佳答案
虽然可行,但在 HtmlService 中相当容易,在 UiApp 中有点难。这是一个 HtmlService 示例:
代码文件
function getGroup(group) {
return GroupsApp.getGroupByEmail(group).getUsers().map(
function(user){return user.getEmail(); });
}
function doGet() {
return HtmlService.createHtmlOutputFromFile("ui");
}
名为“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>
关于google-apps-script - 有没有办法在 Google Apps 脚本的 ui 元素中获得自动完成功能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11416594/