Class: Comments

Comments

handsontable/src/plugins/comments/comments.js, line 75

This plugin allows setting and managing cell comments by either an option in the context menu or with the use of the API.

To enable the plugin, you'll need to set the comments property of the config object to true:

...
comments: true
...

To add comments at the table initialization, define the comment property in the cell config array as in an example below.

Example
...
var hot = new Handsontable(document.getElementById('example'), {
  date: getData(),
  comments: true,
  cell: [
    {row: 1, col: 1, comment: {value: 'Foo'}},
    {row: 2, col: 2, comment: {value: 'Bar'}}
  ]
});

// Access to the Comments plugin instance:
var commentsPlugin = hot.getPlugin('comments');

// Manage comments programmatically:
commentsPlugin.editor.setCommentAtCell(1, 6, 'Comment contents');
commentsPlugin.showAtCell(1, 6);
commentsPlugin.removeCommentAtCell(1, 6);

// You can also set range once and use proper methods:
commentsPlugin.setRange({row: 1, col: 6});
commentsPlugin.setComment('Comment contents');
commentsPlugin.show();
commentsPlugin.removeComment();
...

Members

displayDelayNumber

Delay used when showing/hiding the comments (in milliseconds).

Instance of CommentEditor.

rangeObject

Current cell range.

Methods

handsontable/src/plugins/comments/comments.js, line 196

clearRange()

Clear the currently selected cell.

handsontable/src/plugins/comments/comments.js, line 722

destroy()

Destroy plugin instance.

handsontable/src/plugins/comments/comments.js, line 165

disablePlugin()

Disable plugin for this Handsontable instance.

handsontable/src/plugins/comments/comments.js, line 137

enablePlugin()

Enable plugin for this Handsontable instance.

handsontable/src/plugins/comments/comments.js, line 297

getComment()

Get comment from a cell at the predefined range.

handsontable/src/plugins/comments/comments.js, line 310

getCommentAtCell(row, column)

Get comment from a cell at the provided coordinates.

Parameters:
Name Type Description
row Number

Row index.

column Number

Column index.

handsontable/src/plugins/comments/comments.js, line 453

getCommentMeta(row, column, property){Mixed}

Get the comment related meta information.

Parameters:
Name Type Description
row Number

Row index.

column Number

Column index.

property String

Cell meta property.

Returns: {Mixed}
handsontable/src/plugins/comments/comments.js, line 353

hide()

Hide the comment editor.

handsontable/src/plugins/comments/comments.js, line 130

isEnabled(){Boolean}

Check if the plugin is enabled in the Handsontable settings.

Returns: {Boolean}
handsontable/src/plugins/comments/comments.js, line 364

refreshEditor(force)

Refresh comment editor position and styling.

Parameters:
Name Type Default Description
force Boolean false optional

If true then recalculation will be forced.

handsontable/src/plugins/comments/comments.js, line 266

removeComment(forceRender)

Remove a comment from a cell according to previously set range (see Comments#setRange).

Parameters:
Name Type Default Description
forceRender Boolean true optional

If set to true, the table will be re-rendered at the end of the operation.

handsontable/src/plugins/comments/comments.js, line 287

removeCommentAtCell(row, col, forceRender)

Remove comment from a cell.

Parameters:
Name Type Default Description
row Number

Row index.

col Number

Column index.

forceRender Boolean true optional

If true, the table will be re-rendered at the end of the operation.

handsontable/src/plugins/comments/comments.js, line 227

setComment(value)

Set a comment for a cell according to the previously set range (see Comments#setRange).

Parameters:
Name Type Description
value String

Comment contents.

handsontable/src/plugins/comments/comments.js, line 254

setCommentAtCell(row, col, value)

Set a comment for a cell.

Parameters:
Name Type Description
row Number

Row index.

col Number

Column index.

value String

Comment contents.

handsontable/src/plugins/comments/comments.js, line 189

setRange(range)

Set current cell range to be able to use general methods like Comments#setComment,
Comments#removeComment, Comments#show.

Parameters:
Name Type Description
range Object

Object with from and to properties, each with row and col properties.

handsontable/src/plugins/comments/comments.js, line 319

show(){Boolean}

Show the comment editor accordingly to the previously set range (see Comments#setRange).

Returns: {Boolean} Returns true if comment editor was shown.
handsontable/src/plugins/comments/comments.js, line 342

showAtCell(row, col){Boolean}

Show comment editor according to cell coordinates.

Parameters:
Name Type Description
row Number

Row index.

col Number

Column index.

Returns: {Boolean} Returns true if comment editor was shown.
handsontable/src/plugins/comments/comments.js, line 206

targetIsCellWithComment(event){Boolean}

Check if the event target is a cell containing a comment.

Parameters:
Name Type Description
event Event

DOM event

Returns: {Boolean}
handsontable/src/plugins/comments/comments.js, line 218

targetIsCommentTextArea(event){Boolean}

Check if the event target is a comment textarea.

Parameters:
Name Type Description
event Event

DOM event.

Returns: {Boolean}
handsontable/src/plugins/comments/comments.js, line 431

updateCommentMeta(row, column, metaObject)

Set or update the comment-related cell meta.

Parameters:
Name Type Description
row Number

Row index.

column Number

Column index.

metaObject Object

Object defining all the comment-related meta information.