How to move cell selection up one row?

Tags: #<Tag:0x00007f0b02ba2458>

After a cell in a row is changed in my Handsontable I am doing some calculations, removing the entire row and inserting the row again - this works fine.

Issue is when you edit the cell value and press enter, the on change occurs, the row gets removed and reinserted but the selected cell isn’t on the row directly below the one you just edited, it is a further row down. I assume this is because of the removal and insert.

Is it therefore possible to programatically move the currently select cell to a different location e.g. up one?

Can you share a draft and i/o data David?

I’m not sure how it should shift. Is this relates to the value or te selection itself.

Let me see if I can get a fiddle up

@aleksandra_budnik okay try editing any value on here, press enter on your keyboard - see how the selection skips down 2 rows?

https://jsfiddle.net/9Luoerqh/1531/

Please check if that is correct https://jsfiddle.net/kjz7uvp2/

I’ve added only the 33 line. If you’d like to select a cell below the empty row you just change the changedRow-1 to changedRow

Yes - I think i was over complicating this. I actually just needed this (adapted from what you provided)

hot.selectCell( currentRow +1 , changes[0][1] );

I actually needed currentRow + 1, it’s just because the row being removed and inserted Handsontable must think that row doesn’t exist yet so it selects the next one after the insert.

Fixed now.

Thanks for your help… your support on this forum is fab, all the help and your posts/fiddles help us out greatly :smiley:

1 Like

I’m really glad to hear that :slight_smile: thank you