Search code examples
handsontable

Handsontable add comments to custom context menu


On the Comments page, http://handsontable.com/demo/comments.html, it states that to enable comments you can just add 'comments: true' to the options. However, if you have a custom context menu, how do you add the "Add/Edit Comment" and "Delete Comment" to the menu? The below example will not add the two options to the end of the menu.

contextMenu: {
  items: {
     "undo": {},
     "redo": {}
  }
},
comments: true

Here is a jsFiddle: http://jsfiddle.net/8sk3xrsu/


Solution

  • You need to specify the add/edit and remove comment keys as part of context menu options, similar to "undo" and "redo" options as specified under "items".

    Hence, you above code changes to :

    contextMenu: {
      items: {
        "undo": {},
        "redo": {},
        "commentsAddEdit":{},
        "commentsRemove":{}
      }
    },
    comments: true
    

    Refer to fiddle http://jsfiddle.net/Mazzu/hphdf0uj/ for live demo.

    Hope it will be helpful for you :)