Comments Technical Reference

View as Markdown

Comment State

CommentState

Comment threads for the current session.

This section is not persisted and is not part of Initial State. Load threads with commentOptions.loadCommentThreads and save them with commentOptions.persistCommentThreads.

Extends

BaseState

Comment threads for this session. Each thread belongs to one cell (PrimaryKeyValue and ColumnId) and holds its Comments in order.

CommentThread

Adaptable Comment

AdaptableComment

One comment in a cell's thread.

Value is the text. Timestamp is when it was written. Author.UserName is who wrote it. Uuid identifies the comment.

Id of this AdapTable instance

Author?

{ UserName: string; }

Author of the Comment

Timestamp

number

When Comment was made

Uuid?

TypeUuid

Unique identifier for the Comment

Value

string

Content of the Comment


Comment Options

CommentOptions

Comments on cells. A thread is the list of comments for one cell.

Comments are not stored in AdapTable State. The application loads them with and saves them with .

dateFormat?

string | (() => string)

Date Format string for Comments timestamp

Default

'dd-MM-yyyy HH:mm:ss'

isCellCommentable?

(commentableCellContext:CommentableCellContext) => boolean

Function to configure if a cell can contain Comments

showCommentAction?

'hover' | 'menu'

Whether to show Comments by hovering (default) or via context menu

Default

'hover'

Show the Close Button in the Comments Popup

Default

true

isCellCommentable receives a CommentableCellContext:

Loading and Saving Comments

Comment Options contains 2 functions which developers must provide in order to load and save Comments:


Comment API

CommentApi

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

Add a Comment to a Comment Thread

Create a new Comment Thread

clearComments()
returns

void

Clear all Comment Threads in the grid

Delete a Comment

Delete all Comments for a particular cell

Edit a Comment

Return all Comment Threads in the grid

Return the Comment Thread for a particular cell

Close the Comment Popup

Sets the Comment Threads in the grid


Comment Changed Event

The Comment Changed Event fires whenever a Comment changes.

CommentChangedInfo

The event comprises a single CommentChangedInfo object which provides all the current Comment Threads.

CommentChangedInfo

Payload of the CommentChanged event.

Fires when a comment or comment thread is added, edited or deleted. Loading threads does not fire it.

Extends , so adaptableApi is included.

Every comment thread after the change.

This is the full list commentApi.getAllComments() returns, not only the thread that changed.

Custom application Context provided in AdaptableOptions.adaptableContext

Event Subscription

Subscribing to the Event is done the same way as with all Adaptable Events:

api.eventApi.on('CommentChanged', (eventInfo: CommentChangedInfo) => {
    // do something with the info
});