The Grid
widget displays a grid with a collection of items.
The widget supports suggestions, which help users enter uniform data, and
on-change actions, which are
Actions
that run when a change
occurs in the text input field, like a user adding or deleting text.
A grid supports any number of columns and items. The number of rows is determined by items divided by columns. A grid with 10 items and 2 columns has 5 rows. A grid with 11 items and 2 columns has 6 rows.
Example: a two-column grid with a single item
The following displays a dialog consisting of a grid
widget. It creates a 2 column grid with a single item.
JSON representation and fields
JSON representation |
---|
{ "title": string, "items": [ { object ( |
Fields | |
---|---|
title
|
The text that displays in the grid header. |
items[]
|
The items to display in the grid. |
borderStyle
|
The border style to apply to each grid item. |
columnCount
|
The number of columns to display in the grid. A default value is used if this field isn't specified, and that default value is different depending on where the grid is shown (dialog versus companion). |
onClick
|
This callback is reused by each individual grid item, but with the item's identifier and index in the items list added to the callback's parameters. |
GridItem
JSON representation |
---|
{ "id": string, "image": { object ( |
Fields | |
---|---|
id
|
A user-specified identifier for this grid item. This identifier is returned in the parent grid's
|
image
|
The image that displays in the grid item. |
title
|
The grid item's title. |
subtitle
|
The grid item's subtitle. |
layout
|
The layout to use for the grid item. |
BorderStyle
JSON representation |
---|
{ "type": enum ( |
Fields | |
---|---|
type
|
The border type. |
strokeColor
|
The colors to use when the type is
|
cornerRadius
|
The corner radius for the border. |
BorderType
Enums | |
---|---|
BORDER_TYPE_UNSPECIFIED
|
Don't use. Unspecified. |
NO_BORDER
|
Default value. No border. |
STROKE
|
Outline. |
Color
JSON representation |
---|
{ "red": number, "green": number, "blue": number, "alpha": number } |
Fields | |
---|---|
red
|
The amount of red in the color as a value in the interval [0, 1]. |
green
|
The amount of green in the color as a value in the interval [0, 1]. |
blue
|
The amount of blue in the color as a value in the interval [0, 1]. |
alpha
|
The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation:
This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0). |
OnClick
Represents how to respond when users click an interactive element on a card, such as a button.
JSON representation |
---|
{ // Union field |
Fields | |
---|---|
Union field
|
|
action
|
If specified, an action is triggered by this
|
openLink
|
If specified, this
|
openDynamicLinkAction
|
An add-on triggers this action when the action needs to open a link. This differs from the
|
card
|
A new card is pushed to the card stack after clicking if specified. Supported by Google Workspace Add-ons, but not Google Chat apps. |
Action
An action that describes the behavior when the form is submitted. For example, you can invoke an Apps Script script to handle the form. If the action is triggered, the form values are sent to the server.
JSON representation |
---|
{ "function": string, "parameters": [ { object ( |
Fields | |
---|---|
function
|
A custom function to invoke when the containing element is clicked or othrwise activated. For example usage, see Create interactive cards. |
parameters[]
|
List of action parameters. |
loadIndicator
|
Specifies the loading indicator that the action displays while making the call to the action. |
persistValues
|
Indicates whether form values persist after the action. The default value is
If
If
|
interaction
|
Optional. Required when opening a dialog. What to do in response to an interaction with a user, such as a user clicking a button in a card message.
If unspecified, the app responds by executing an
By specifying an
Supported by Chat apps, but not Google Workspace Add-ons. If specified for an add-on, the entire card is stripped and nothing is shown in the client. |
OpenLink
Represents an
onClick
event that opens a hyperlink.
JSON representation |
---|
{ "url": string, "openAs": enum ( |
Fields | |
---|---|
url
|
The URL to open. |
openAs
|
How to open a link. Not supported by Chat apps. |
onClose
|
Whether the client forgets about a link after opening it, or observes it until the window closes. Not supported by Chat apps. |
Troubleshoot
When a Google Chat app or card returns an error, the Chat interface surfaces a message saying "Something went wrong." or "Unable to process your request." Sometimes the Chat UI doesn't display any error message, but the Chat app or card produces an unexpected result; for example, a card message might not appear.
Although an error message might not display in the Chat UI, descriptive error messages and log data are available to help you fix errors when error logging for Chat apps is turned on. For help viewing, debugging, and fixing errors, see Troubleshoot and fix Google Chat errors.