updateSettings do not work after row moving

Tags: #<Tag:0x00007f51b592c5a8> #<Tag:0x00007f51b592c468>

In the grid, the editability of columns should depend on the value in column 1 (Index 0).

  • If the value in column 1 is “Product”, all cells should be writable except for columns 2 and 10.
  • If the value is “Text”, all cells should be read-only except for columns 1 and 4, which should be editable.

The corresponding updateSettings is structured as follows:

hot.updateSettings({
cells(row, col) {
return (hot.getData()[row][0] == ‘Text’ && col != 0 && col != 3) ||
(hot.getData()[row][0] == ‘Produkt’ && (col == 1 || col == 9)) ||
(hot.getData()[row][0] == undefined && col != 0) ? { readOnly: true } : { readOnly: false };
},
});

When the user moves rows within the grid, the individual cell properties are not updated. If a Product row and a Text row are swapped, the new Product row inherits the properties of the Text row and vice versa.

How can this be solved? Thanks in advance.

Hi @sfischer

Thank you for contacting us. I looked for a similar reported issue but can’t find anything related. Can you please prepare a code demo with the steps to reproduce the problem? It will be easier to investigate this way.

Hello Adrian!

Here is some example code: https://jsfiddle.net/aogtm6zb/

When you move the first row with the second row, the cells are not updated.
When you add a new row, everything works fine.

Hi @sfischer

Thank you for the demo. I checked it and move the first row in a place of the second one, but everything seems to work fine. Can you please explain a bit more what result do you expect?

For example: First row and Col2 is editable, second row and Col2 is not editable. This behavior should be handled by the value in Col0 -> when the value is “Produkt” then certain cells should be editable, when the value is “Text” certain cells should be editable.

When you move/switch the rows, the editing of the cells are swapped. First row and Col2 is now editable (which shouldn’t because of the “Text” value), and second row and Col2 is not editable (but it should editable because of the “Produkt” value).

@sfischer,
Hi,
I think you need to use to toVisualRow . Does this work for you: https://jsfiddle.net/wodxs9pj/?

@timeflys54321
Thanks, that works perfect. :+1:

@timeflys54321

Thank you for providing the solution.

1 Like