Comments
Options
comments
comments.comments : boolean | Array<object>
The comments option configures the Comments plugin.
You can set the comments option to one of the following:
| Setting | Description |
|---|---|
true | - Enable the Comments plugin- Add comment menu items to the context menu |
false | Disable the Comments plugin |
| An object | - Enable the Comments plugin- Add comment menu items to the context menu - Configure comment settings |
If you set the comments option to an object, you can configure the following comment options:
| Option | Possible settings | Description |
|---|---|---|
displayDelay | A number (default: 250) | Display comments after a delay (in milliseconds) |
readOnly | true | false (default) | true: Make comments read-only |
style | An object | Set comment boxes’ width and height (in pixels) |
Read more:
This option can only be set at the grid level.
It has no effect when set in the columns, cells, or cell options.
Default: false
Example
// enable the `Comments` plugincomments: true,
// enable the `Comments` plugin// and configure its settingscomments: { // display all comments with a 1-second delay displayDelay: 1000, // make all comments read-only readOnly: true, // set the default size of all comment boxes style: { width: 300, height: 100 }}Members
DEFAULT_SETTINGS
Comments.DEFAULT_SETTINGS
Returns the default settings applied when the plugin is enabled without explicit configuration.
PLUGIN_KEY
Comments.PLUGIN_KEY
Returns the plugin key used to identify this plugin in Handsontable settings.
PLUGIN_PRIORITY
Comments.PLUGIN_PRIORITY
Returns the priority order used to determine the order in which plugins are initialized.
range
comments.range : object
Current cell range, an object with from property, with row and col properties (e.q. {from: {row: 1, col: 6}}).
Methods
clearRange
comments.clearRange()
Clears the currently selected cell.
destroy
comments.destroy()
Destroys the plugin instance.
disablePlugin
comments.disablePlugin()
Disables the plugin functionality for this Handsontable instance.
enablePlugin
comments.enablePlugin()
Enables the plugin functionality for this Handsontable instance.
focusEditor
comments.focusEditor()
Focuses the comments editor element.
getComment
comments.getComment() ⇒ string | undefined
Gets comment from a cell according to previously set range (see Comments#setRange).
Returns: string | undefined - Returns a content of the comment.
getCommentAtCell
comments.getCommentAtCell(row, column) ⇒ string | undefined
Gets comment from a cell at the provided coordinates.
| Param | Type | Description |
|---|---|---|
| row | number | Visual row index. |
| column | number | Visual column index. |
Returns: string | undefined - Returns a content of the comment.
getCommentMeta
comments.getCommentMeta()
Returns the value of a specific meta property from the comment attached to the given cell.
hide
comments.hide()
Hides the comment editor.
isEnabled
comments.isEnabled() ⇒ boolean
Checks if the plugin is enabled in the handsontable settings. This method is executed in Hooks#beforeInit
hook and if it returns true then the Comments#enablePlugin method is called.
refreshEditor
comments.refreshEditor([force])
Refreshes comment editor position and styling.
| Param | Type | Default | Description |
|---|---|---|---|
| [force] | boolean | false | optional If true then recalculation will be forced. |
removeComment
comments.removeComment([forceRender])
Removes a comment from a cell according to previously set range (see Comments#setRange).
| Param | Type | Default | Description |
|---|---|---|---|
| [forceRender] | boolean | true | optional If set to true, the table will be re-rendered at the end of the operation. |
removeCommentAtCell
comments.removeCommentAtCell(row, column, [forceRender])
Removes a comment from a specified cell.
| Param | Type | Default | Description |
|---|---|---|---|
| row | number | Visual row index. | |
| column | number | Visual column index. | |
| [forceRender] | boolean | true | optional If true, the table will be re-rendered at the end of the operation. |
setComment
comments.setComment(value)
Sets a comment for a cell according to the previously set range (see Comments#setRange).
| Param | Type | Description |
|---|---|---|
| value | string | Comment contents. |
setCommentAtCell
comments.setCommentAtCell(row, column, value)
Sets a comment for a specified cell.
| Param | Type | Description |
|---|---|---|
| row | number | Visual row index. |
| column | number | Visual column index. |
| value | string | Comment contents. |
setRange
comments.setRange(range)
Sets the current cell range to be able to use general methods like Comments#setComment, Comments#removeComment, Comments#show.
| Param | Type | Description |
|---|---|---|
| range | object | Object with from property, each with row and col properties. |
show
comments.show() ⇒ boolean
Shows the comment editor accordingly to the previously set range (see Comments#setRange).
Returns: boolean - Returns true if comment editor was shown.
showAtCell
comments.showAtCell(row, column) ⇒ boolean
Shows comment editor according to cell coordinates.
| Param | Type | Description |
|---|---|---|
| row | number | Visual row index. |
| column | number | Visual column index. |
Returns: boolean - Returns true if comment editor was shown.
updateCommentMeta
comments.updateCommentMeta(row, column, metaObject)
Sets or update the comment-related cell meta.
| Param | Type | Description |
|---|---|---|
| row | number | Visual row index. |
| column | number | Visual column index. |
| metaObject | object | Object defining all the comment-related meta information. |
updatePlugin
comments.updatePlugin()
Updates the plugin’s state.
This method is executed when updateSettings() is invoked with any of the following configuration options: