Help needed to make Comments ReadOnly

Tags: #<Tag:0x00007f0b096ff750>

Hi,

I need to make Comments readOnly in some specific conditions (cell based).
I found setReadOnlyState(state) in the Comments documentation but can’t make it work.
As a translation C.CONTEXTMENU_ITEMS_READ_ONLY_COMMENT exists in languages I guess it’s possible.

I can disable the contextMenu comment options but then the comments are not accessible.
Another option is to use
document.getElementsByClassName("htCommentTextArea")[0].readOnly = true;
but it’s tricky if using multiple HOT instances …

Does someone have a working example using setReadOnlyState or a way to set Comments to readOnly ?

Thanks,

Olivier

Hi @olivier

I can see that a a similar discussion has been already raised some time ago here https://github.com/handsontable/handsontable/issues/2136 on our Github board.

You can use cell or cells method like this

cell: [
{row: 1, col: 1, comment: {value: ‘Some comment’, readOnly: true}},
{row: 2, col: 2, comment: {value: ‘More comments’, readOnly: true}}
]

and use updateSettings to change it after user changes the data that it depens on.