是否可以使用GAS在列表框中使用复选框?

时间:2014-07-16 13:47:28

标签: google-apps-script

使用GAS我想在列表框中使用复选框(并检查其中的几个)。这可能吗?

我想避免使用像flextable或甚至树一样的替代品。

2 个答案:

答案 0 :(得分:1)

UiApp服务不支持组合这两个元素。 ListBox支持多项选择( shift -click, ctrl -click),您可以将多个CheckBox项置于{{1}为您的用户提供逻辑分组。

如果您使用VerticalPanel作为用户界面,则会有更多选项,包括Eric Hynd's jQueryUI Multi-Select widget等小部件:

screenshot

以下是Google文档侧边栏中相同小部件的外观(代码如下,但没有任何输入处理):

screenshot

Code.gs

HtmlService

Sidebar.html

/**
 * Creates a menu entry in the Google Docs UI when the document is opened.
 *
 * @param {object} e The event parameter for a simple onOpen trigger. To
 *     determine which authorization mode (ScriptApp.AuthMode) the trigger is
 *     running in, inspect e.authMode.
 */
function onOpen(e) {
  DocumentApp.getUi().createAddonMenu()
      .addItem('Start', 'showSidebar')
      .addToUi();
}

/**
 * Runs when the add-on is installed.
 *
 * @param {object} e The event parameter for a simple onInstall trigger. To
 *     determine which authorization mode (ScriptApp.AuthMode) the trigger is
 *     running in, inspect e.authMode. (In practice, onInstall triggers always
 *     run in AuthMode.FULL, but onOpen triggers may be AuthMode.LIMITED or
 *     AuthMode.NONE.)
 */
function onInstall(e) {
  onOpen(e);
}

/**
 * Opens a sidebar in the document containing the add-on's user interface.
 */
function showSidebar() {
  var ui = HtmlService.createHtmlOutputFromFile('Sidebar')
      .setTitle('MultiSelect').setSandboxMode(HtmlService.SandboxMode.NATIVE);
  DocumentApp.getUi().showSidebar(ui);
}

答案 1 :(得分:0)

我认为你的意思是uiService。不可能。
可以在htmlService中使用。