GridItem

The items users interact with within a grid widget.

Available for Google Workspace add-ons and Google Chat apps.

To call an enum, you call its parent class, name, and property. For example, `
CardService.GridItemLayout.TEXT_BELOW`.

```javascript
const gridItem = CardService.newGridItem()
                     .setIdentifier('itemA')
                     .setTitle('This is a cat')
                     .setImage(CardService.newImageComponent())
                     .setLayout(CardService.GridItemLayout.TEXT_BELOW);
```

### Methods

| Method | Return type | Brief description |
|---|---|---|
| `https://developers.google.com/apps-script/reference/card-service/grid-item#setIdentifier(String)` | `https://developers.google.com/apps-script/reference/card-service/grid-item#` | Sets the identifier for the grid item. |
| `https://developers.google.com/apps-script/reference/card-service/grid-item#setImage(ImageComponent)` | `https://developers.google.com/apps-script/reference/card-service/grid-item#` | Sets the image for this grid item. |
| `https://developers.google.com/apps-script/reference/card-service/grid-item#setLayout(GridItemLayout)` | `https://developers.google.com/apps-script/reference/card-service/grid-item#` | Sets the layout of text and image for the grid item. |
| `https://developers.google.com/apps-script/reference/card-service/grid-item#setSubtitle(String)` | `https://developers.google.com/apps-script/reference/card-service/grid-item#` | Sets the subtitle of the grid item. |
| `https://developers.google.com/apps-script/reference/card-service/grid-item#setTextAlignment(HorizontalAlignment)` | `https://developers.google.com/apps-script/reference/card-service/grid-item#` | Sets the horizontal alignment of the grid item. |
| `https://developers.google.com/apps-script/reference/card-service/grid-item#setTitle(String)` | `https://developers.google.com/apps-script/reference/card-service/grid-item#` | Sets the title text of the grid item. |

## Detailed documentation

### `setIdentifier(id)`

Sets the identifier for the grid item. When a user clicks this grid item, this ID is returned
in the parent grid's on_click call back parameters.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `id` | `String` | The ID. |

#### Return


`https://developers.google.com/apps-script/reference/card-service/grid-item#` --- This object, for chaining.

*** ** * ** ***

### `setImage(image)`

Sets the image for this grid item.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `image` | `https://developers.google.com/apps-script/reference/card-service/image-component` | The ImageComponent object. |

#### Return


`https://developers.google.com/apps-script/reference/card-service/grid-item#` --- This object, for chaining.

*** ** * ** ***

### `setLayout(layout)`

Sets the layout of text and image for the grid item. Default is TEXT_BELOW

#### Parameters

| Name | Type | Description |
|---|---|---|
| `layout` | `https://developers.google.com/apps-script/reference/card-service/grid-item-layout` | The layout setting. |

#### Return


`https://developers.google.com/apps-script/reference/card-service/grid-item#` --- This object, for chaining.

*** ** * ** ***

### `setSubtitle(subtitle)`

Sets the subtitle of the grid item.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `subtitle` | `String` | The subtitle text. |

#### Return


`https://developers.google.com/apps-script/reference/card-service/grid-item#` --- This object, for chaining.

*** ** * ** ***

### `setTextAlignment(alignment)`

Sets the horizontal alignment of the grid item. Default is START.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `alignment` | `https://developers.google.com/apps-script/reference/card-service/horizontal-alignment` | The alignment setting. |

#### Return


`https://developers.google.com/apps-script/reference/card-service/grid-item#` --- This object, for chaining.

*** ** * ** ***

### `setTitle(title)`

Sets the title text of the grid item.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `title` | `String` | The title text. |

#### Return


`https://developers.google.com/apps-script/reference/card-service/grid-item#` --- This object, for chaining.