Class UpdatedWidget
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
更新了 widget
更新后的 widget 的响应。用于为 SelectionInput
中的多选菜单提供自动补全选项。
const updatedWidget = CardService.newUpdatedWidget()
.addItem(
'item_one_title',
'item_one_value',
false,
'item_one_uri',
'item_one_bottom_text',
)
.addItem(
'item_two_title',
'item_two_value',
false,
'item_two_uri',
'item_two_bottom_text',
);
仅适用于 Google Chat 应用。不适用于 Google Workspace 插件。
详细文档
addItem(text, value, selected, startIconUri, bottomText)
添加了可供选择的新项。
const updatedWidget = CardService.newUpdatedWidget()
.addItem(
'item_one_title',
'item_one_value',
false,
'item_one_uri',
'item_one_bottom_text',
)
.addItem(
'item_two_title',
'item_two_value',
false,
'item_two_uri',
'item_two_bottom_text',
);
仅适用于 Google Chat 应用。不适用于 Google Workspace 插件。
参数
名称 | 类型 | 说明 |
text | Object | 要显示的此项的文本。非字符串基元参数会自动转换为字符串。 |
value | Object | 通过回调发送的表单输入值。非字符串基元参数会自动转换为字符串。 |
selected | Boolean | 相应项是否默认处于选中状态。如果选择输入项仅接受一个值(例如单选按钮或下拉菜单),请仅为一个项设置此字段。 |
startIconUri | Object | 对于多选菜单,是显示在项文本字段旁边的图标的网址。支持 PNG 和 JPEG 文件。 |
bottomText | Object | 对于多选菜单,是显示在项的文本字段下方的文本说明或标签。 |
返回
UpdatedWidget
- 此对象,用于链式调用。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003e\u003ccode\u003eUpdatedWidget\u003c/code\u003e provides autocomplete options for multiselect menus in SelectionInput, specifically for Google Chat apps.\u003c/p\u003e\n"],["\u003cp\u003eIt allows adding items with customizable text, value, selection state, icon, and bottom text using the \u003ccode\u003eaddItem\u003c/code\u003e method.\u003c/p\u003e\n"],["\u003cp\u003eThis functionality is exclusive to Google Chat apps and is not available for Google Workspace Add-ons.\u003c/p\u003e\n"]]],[],null,["# Class UpdatedWidget\n\nUpdatedWidget\n\nThe response of the updated widget. Used to provide autocomplete options for multiselect menu in\n[SelectionInput](/apps-script/reference/card-service/selection-input).\n\n```javascript\nconst updatedWidget = CardService.newUpdatedWidget()\n .addItem(\n 'item_one_title',\n 'item_one_value',\n false,\n 'item_one_uri',\n 'item_one_bottom_text',\n )\n .addItem(\n 'item_two_title',\n 'item_two_value',\n false,\n 'item_two_uri',\n 'item_two_bottom_text',\n );\n```\n\nOnly available for Google Chat apps. Not available for Google Workspace add-ons. \n\n### Methods\n\n| Method | Return type | Brief description |\n|-----------------------------------------------------------------------------------------------------------|--------------------|---------------------------------------|\n| [addItem(text, value, selected, startIconUri, bottomText)](#addItem(Object,Object,Boolean,Object,Object)) | [UpdatedWidget](#) | Adds a new item that can be selected. |\n\nDetailed documentation\n----------------------\n\n### `add``Item(text, value, selected, startIconUri, bottomText)`\n\nAdds a new item that can be selected.\n\n```javascript\nconst updatedWidget = CardService.newUpdatedWidget()\n .addItem(\n 'item_one_title',\n 'item_one_value',\n false,\n 'item_one_uri',\n 'item_one_bottom_text',\n )\n .addItem(\n 'item_two_title',\n 'item_two_value',\n false,\n 'item_two_uri',\n 'item_two_bottom_text',\n );\n```\nOnly available for Google Chat apps. Not available for Google Workspace add-ons.\n\n#### Parameters\n\n| Name | Type | Description |\n|--------------------|-----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `text` | `Object` | The text to be shown for this item. Non-string primitive arguments are converted to strings automatically. |\n| `value` | `Object` | The form input value that is sent via the callback. Non-string primitive arguments are converted to strings automatically. |\n| `selected` | `Boolean` | Whether the item is selected by default. If the selection input only accepts one value (such as for radio buttons or a dropdown menu), only set this field for one item. |\n| `start``Icon``Uri` | `Object` | For multiselect menus, the URL for the icon displayed next to the item's text field. Supports PNG and JPEG files. |\n| `bottom``Text` | `Object` | For multiselect menus, a text description or label that's displayed below the item's text field. |\n\n#### Return\n\n\n[UpdatedWidget](#) --- This object, for chaining."]]