Class: Comments

Comments

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

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 object with extra predefined plugin config:

...
comments: {
  displayDelay: 1000
}
...

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

displaySwitchDisplaySwitch

Instance of DisplaySwitch.

Instance of CommentEditor.

rangeObject

Current cell range.

Methods

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

clearRange()

Clear the currently selected cell.

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

destroy()

Destroy plugin instance.

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

disablePlugin()

Disable plugin for this Handsontable instance.

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

enablePlugin()

Enable plugin for this Handsontable instance.

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

getComment()

Get comment from a cell at the predefined range.

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

getCommentAtCell(row, column)

Get comment from a cell at the provided coordinates.

Parameters:
Name Type Description
row Number

Visual row index.

column Number

Visual column index.

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

getCommentMeta(row, column, property){Mixed}

Get the comment related meta information.

Parameters:
Name Type Description
row Number

Visual row index.

column Number

Visual column index.

property String

Cell meta property.

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

getDisplayDelaySetting(){Number|undefined}

Get displayDelay setting of comment plugin.

Returns: {Number|undefined}
handsontable/src/plugins/comments/comments.js, line 378

hide()

Hide the comment editor.

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

isEnabled(){Boolean}

Check if the plugin is enabled in the Handsontable settings.

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

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 291

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 312

removeCommentAtCell(row, col, forceRender)

Remove comment from a cell.

Parameters:
Name Type Default Description
row Number

Visual row index.

col Number

Visual 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 252

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 279

setCommentAtCell(row, col, value)

Set a comment for a cell.

Parameters:
Name Type Description
row Number

Visual row index.

col Number

Visual column index.

value String

Comment contents.

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

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 344

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 367

showAtCell(row, col){Boolean}

Show comment editor according to cell coordinates.

Parameters:
Name Type Description
row Number

Visual row index.

col Number

Visual column index.

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

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 243

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 456

updateCommentMeta(row, column, metaObject)

Set or update the comment-related cell meta.

Parameters:
Name Type Description
row Number

Visual row index.

column Number

Visual column index.

metaObject Object

Object defining all the comment-related meta information.

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

updatePlugin()

Update plugin for this Handsontable instance.