Set Read Only cell doesn't work after filtering

Tags: #<Tag:0x00007efc6507da60>

Hi,

I am encountering an issue about set cell read only dynamically by the data in the handsontable. I want that if the row is not a Draft, the row should be read only.
It works okay before filter applied, but if I filter the data by de-selecting column B 201904 201901 201907, then it has an error that showing a draft as read only which is not what I want.

To recreate the issue,
set filter of B column to { 201904 , 201907, 201909
} or { 201907, 201909 } or { 201909}
And it is also messed up after doing a column sorting, e.g. on column B
((need to enable column sorting first)

Please check the jksfiddle below.

https://jsfiddle.net/jnh4mbkx/

Best,
Terry

Hi Terry,

here’s an article with cell dependencies examples https://handsontable.com/blog/articles/2016/4/expand-your-app-with-cell-dependencies
You may wan to use afterChange hook to run the checking for ‘Draft’ method.

No, the afterChange hook only listen for cell data change, it doesn’t detect any filter change or any column sorting. In my case, the column for ‘Draft’ is a read only column, so the cell data is fixed but user may play around to filter or sort etc.

Hey @marius.editoiu

for filtering there’s afterFilter hook.

Unfortunately, we do not have a hook that will be called on each update and at the same time can guarantee good performance.

The afterRender hook will work for all the changes and filters but it will also be called too many times (a couple of times for a single cell).

Ah I see.
Thank you so much for your help and the quick response.
I appreciate.

Please let me know about the progress.

I finally come up with a solution by using afterFilter, and set the read-only cells by using hot.getCellMeta(m, n).readOnly = true if the hot.getDataAtCell(m, 0) is a ‘Draft’. I have toi call this method on two hooks, afterInit, and afterFilter .

Hi @marius.editoiu

That’s a great (and supported) way to acheieve this goal. Thank you for the update.

Thank you