Comments Technical Reference

Summary

  • Comment Options allows developers to configure which Cells can receive Comments
  • Comment API provides run time access to Comments

Comment State

There is no Comment State due to the collaborative nature of comments.

Instead Comment Threads are stored using the functions provided in Comment Options.


Comment Options

The Comment Options section of Adaptable Options contains properties used to configure Comments:

PropertyTypeDescriptionDefault
dateFormatstring | (() => string)Date Format string for Comments timestamp'dd-MM-yyyy HH:mm:ss'
isCellCommentable(commentableCellContext:CommentableCellContext) => booleanFunction to configure if a cell can contain Comments
showCommentAction'hover' | 'menu'Whether to show Comments by hovering (default) or via context menu'hover'
showPopupCloseButtonbooleanShow the Close Button in the Comments Popuptrue

Loading and Saving Comments

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

MethodReturnsDescription
loadCommentThreads(commentLoadContext)Promise<CommentThread[]>Loads the Comment Threads
persistCommentThreads(commentThreads)Promise<void>Persists the current Comment Threads

Comment Changed Event

The Comment Changed Event fires whenever a Comment changes.

CommentChangedInfo

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

PropertyTypeDescription
commentThreadsCommentThread[]All current Comment Threads
adaptableContextanyCustom 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
});

Comment API

Full programmatic access to Comments is available in Comment API section of Adaptable API.

MethodReturnsDescription
addComment(commentText, cellAddress)voidAdd a Comment to a Comment Thread
addCommentThread(commentThread)voidCreate a new Comment Thread
clearComments()voidClear all Comment Threads in the grid
deleteComment(comment, cellAddress)voidDelete a Comment
deleteCommentThread(cellAddress)voidDelete all Comments for a particular cell
editComment(comment, cellAddress)voidEdit a Comment
getAllComments()CommentThread[]Return all Comment Threads in the grid
getCommentThreadForCell(cellAddress)CommentThread | undefinedReturn the Comment Thread for a particular cell
hideCommentsPopup()voidClose the Comment Popup
setComments(commentThreads)voidSets the Comment Threads in the grid