可在一组预定义选项之间进行选择的输入字段。
var checkboxGroup = CardService.newSelectionInput() .setType(CardService.SelectionInputType.CHECK_BOX) .setTitle("A group of checkboxes. Multiple selections are allowed.") .setFieldName("checkbox_field") .addItem("checkbox one title", "checkbox_one_value", false) .addItem("checkbox two title", "checkbox_two_value", true) .addItem("checkbox three title", "checkbox_three_value", true) .setOnChangeAction(CardService.newAction() .setFunctionName("handleCheckboxChange")); var radioGroup = CardService.newSelectionInput() .setType(CardService.SelectionInputType.RADIO_BUTTON) .setTitle("A group of radio buttons. Only a single selection is allowed.") .setFieldName("checkbox_field") .addItem("radio button one title", "radio_one_value", true) .addItem("radio button two title", "radio_two_value", false) .addItem("radio button three title", "radio_three_value", false);
方法
方法 | 返回类型 | 简介 |
---|---|---|
addItem(text, value, selected) | SelectionInput | 添加可选择的新内容。 |
setFieldName(fieldName) | SelectionInput | 设置用于在有界面互动时生成的事件对象中标识此选择输入的键。 |
setOnChangeAction(action) | SelectionInput | 设置每当选择输入更改时要执行的 Action 。 |
setTitle(title) | SelectionInput | 设置要在输入字段之前显示的标题。 |
setType(type) | SelectionInput | 设置此输入源的类型。 |
详细文档
addItem(text, value, selected)
添加可选择的新内容。
参数
名称 | 类型 | 说明 |
---|---|---|
text | Object | 要为此项内容显示的文字。非字符串基元参数会自动转换为字符串。 |
value | Object | 通过回调发送的表单输入值。非字符串基元参数会自动转换为字符串。 |
selected | Boolean | 内容应以选中状态还是未选中状态开头。 |
返回
SelectionInput
- 此对象,用于实现链式连接。
setFieldName(fieldName)
设置用于在有界面互动时生成的事件对象中标识此选择输入的键。不会向用户显示。必需且必须是唯一的。
参数
名称 | 类型 | 说明 |
---|---|---|
fieldName | String | 分配给此输入的名称。 |
返回
SelectionInput
- 此对象,用于实现链式连接。