Class: Comments

Comments

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

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
...

OR by declaring it as an object with the plugin settings.
For example, to enable it with a pre-defined comment added to cell at (1,1), you'd need to set it up like this:

comments: {row: 1, col: 1, comment: "Test comment"}
Example
...
var hot = new Handsontable(document.getElementById('example'), {
  date: getData(),
  comments: true,
  cell: [
    {row: 1, col: 1, comment: 'Foo'},
    {row: 2, col: 2, comment: 'Bar'}
  ]
});
// Access to the Comments plugin instance:
var commentsPlugin = hot.getPlugin('comments');

// Managing comments programmatically:
commentsPlugin.editor.setValue('Cell comment text');
commentsPlugin.showAtCell(1, 6);
commentsPlugin.saveCommentAtCell(1, 6);
commentsPlugin.removeCommentAtCell(1, 6);
...
// You can also set range once and use proper methods:
commentsPlugin.setRange({row: 1, col: 6});
commentsPlugin.editor.setValue('Cell comment text');

commentsPlugin.show();
commentsPlugin.saveComment();
commentsPlugin.removeComment();
...

Members

Instance of CommentEditor.

rangeObject

Current cell range.

Methods

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

clearRange()

Clear current selected cell.

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

destroy()

Destroy plugin instance.

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

disablePlugin()

Disable plugin for this Handsontable instance.

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

enablePlugin()

Enable plugin for this Handsontable instance.

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

hide()

Hide all comments input editors.

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

isEnabled(){Boolean}

Check if the plugin is enabled in the handsontable settings.

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

refreshEditorPosition(force)

Refresh comment editor position.

Parameters:
Name Type Default Description
force Boolean false optional

If true then recalculation will be forced.

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

removeComment()

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

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

removeCommentAtCell(row, col)

Remove comment.

Parameters:
Name Type Description
row Number

Row index.

col Number

Column index.

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

saveComment()

Save comment for cell according to previously set range (see Comments#setRange).

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

saveCommentAtCell(row, col)

Save comment for cell.

Parameters:
Name Type Description
row Number

Row index.

col Number

Column index.

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

setRange(range)

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

Parameters:
Name Type Description
range Object

Object with row and col properties.

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

show(){Boolean}

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

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

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 showed.
handsontable/src/plugins/comments/comments.js, line 180

targetIsCellWithComment(event){Boolean}

Check if 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 190

targetIsCommentTextArea(event){Boolean}

Check if event target is a comment textarea.

Parameters:
Name Type Description
event Event

DOM event.

Returns: {Boolean}