# CommentApi

Canonical page: https://www.adaptabletools.com/docs/reference/commentapi

Comments on cells. A thread holds the comments for one cell.

```ts title="TypeScript"
export interface CommentApi 
```

## Methods

| Method | Returns | Description |
| --- | --- | --- |
| [addComment(commentText, cellAddress)](https://www.adaptabletools.com/docs/reference/commentapi.md#addcomment) | `void` | Add a Comment to a Comment Thread |
| [addCommentThread(commentThread)](https://www.adaptabletools.com/docs/reference/commentapi.md#addcommentthread) | `void` | Create a new Comment Thread |
| [clearComments()](https://www.adaptabletools.com/docs/reference/commentapi.md#clearcomments) | `void` | Clear all Comment Threads in the grid |
| [deleteComment(comment, cellAddress)](https://www.adaptabletools.com/docs/reference/commentapi.md#deletecomment) | `void` | Delete a Comment |
| [deleteCommentThread(cellAddress)](https://www.adaptabletools.com/docs/reference/commentapi.md#deletecommentthread) | `void` | Delete all Comments for a particular cell |
| [editComment(comment, cellAddress)](https://www.adaptabletools.com/docs/reference/commentapi.md#editcomment) | `void` | Edit a Comment |
| [getAllComments()](https://www.adaptabletools.com/docs/reference/commentapi.md#getallcomments) | [`CommentThread`](https://www.adaptabletools.com/docs/reference/commentthread.md)`[]` | Return all Comment Threads in the grid |
| [getCommentThreadForCell(cellAddress)](https://www.adaptabletools.com/docs/reference/commentapi.md#getcommentthreadforcell) | [`CommentThread`](https://www.adaptabletools.com/docs/reference/commentthread.md)` \| undefined` | Return the Comment Thread for a particular cell |
| [hideCommentsPopup()](https://www.adaptabletools.com/docs/reference/commentapi.md#hidecommentspopup) | `void` | Close the Comment Popup |
| [setComments(commentThreads)](https://www.adaptabletools.com/docs/reference/commentapi.md#setcomments) | `void` | Sets the Comment Threads in the grid |

## Method Details

### addComment

Add a Comment to a Comment Thread

```ts title="TypeScript"
addComment(commentText: string, cellAddress: CellAddress): void;
```

###### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| commentText | `string` | Text of the comment |
| cellAddress | [`CellAddress`](https://www.adaptabletools.com/docs/reference/celladdress.md) | Cell the comment is added to |

###### Returns

`void`

### addCommentThread

Create a new Comment Thread

```ts title="TypeScript"
addCommentThread(commentThread: CommentThread): void;
```

###### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| commentThread | [`CommentThread`](https://www.adaptabletools.com/docs/reference/commentthread.md) | Thread to create, including the cell it belongs to |

###### Returns

`void`

### clearComments

Clear all Comment Threads in the grid

```ts title="TypeScript"
clearComments(): void;
```

###### Returns

`void`

### deleteComment

Delete a Comment

```ts title="TypeScript"
deleteComment(comment: AdaptableComment, cellAddress: CellAddress): void;
```

###### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| comment | [`AdaptableComment`](https://www.adaptabletools.com/docs/reference/adaptablecomment.md) | Comment to delete |
| cellAddress | [`CellAddress`](https://www.adaptabletools.com/docs/reference/celladdress.md) | Cell the comment belongs to |

###### Returns

`void`

### deleteCommentThread

Delete all Comments for a particular cell

```ts title="TypeScript"
deleteCommentThread(cellAddress: CellAddress): void;
```

###### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| cellAddress | [`CellAddress`](https://www.adaptabletools.com/docs/reference/celladdress.md) | Cell whose comments are deleted |

###### Returns

`void`

### editComment

Edit a Comment

```ts title="TypeScript"
editComment(comment: AdaptableComment, cellAddress?: CellAddress): void;
```

###### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| comment | [`AdaptableComment`](https://www.adaptabletools.com/docs/reference/adaptablecomment.md) | Comment to edit |
| cellAddress | [`CellAddress`](https://www.adaptabletools.com/docs/reference/celladdress.md) | Location of the comment, if not provided all comments will be traversed to find the comment |

###### Returns

`void`

### getAllComments

Return all Comment Threads in the grid

```ts title="TypeScript"
getAllComments(): CommentThread[];
```

###### Returns

 Return all Comment Threads in the grid

[`CommentThread`](https://www.adaptabletools.com/docs/reference/commentthread.md)`[]`

### getCommentThreadForCell

Return the Comment Thread for a particular cell

```ts title="TypeScript"
getCommentThreadForCell(cellAddress: CellAddress): CommentThread | undefined;
```

###### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| cellAddress | [`CellAddress`](https://www.adaptabletools.com/docs/reference/celladdress.md) | Cell to read |

###### Returns

 Return the Comment Thread for a particular cell

[`CommentThread`](https://www.adaptabletools.com/docs/reference/commentthread.md)` | undefined`

### hideCommentsPopup

Close the Comment Popup

```ts title="TypeScript"
hideCommentsPopup(): void;
```

###### Returns

`void`

### setComments

Sets the Comment Threads in the grid

```ts title="TypeScript"
setComments(commentThreads: CommentThread[]): void;
```

###### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| commentThreads | [`CommentThread`](https://www.adaptabletools.com/docs/reference/commentthread.md)`[]` | new cell comments |

###### Returns

`void`
