KeyTable focus doesn't follow edited row/cell when row is resorted

KeyTable focus doesn't follow edited row/cell when row is resorted

bg7bg7 Posts: 44Questions: 6Answers: 0

Link to test case:
https://editor.datatables.net/examples/extensions/excel.html

Description of problem:
If you edit a cell that's in a column that's sorted and the row gets resorted to a new location, the KeyTable focus doesn't follow the row/cell. In the example above, if you change the first cell in the first row (sorted by first name by default) from (e.g.) 'Airi' to 'Biri' and then press enter or tab that row will get resorted to a new location a couple rows down. Changing it to 'Ciri' pushes it to the next results page. Meanwhile, the KeyTable focus remains on the first row which is now different. Our users have found this confusing and I'm wondering if there is a way to get KeyTable's focus to follow the row you're editing even if it gets resorted? I noticed that the edited row is getting briefly highlighted after the edit completes (assuming the edited row is still on the same page) and am hoping there's a way to piggyback off of that to refocus KeyTable.

Thanks.

Ben

Replies

  • bg7bg7 Posts: 44Questions: 6Answers: 0

    In case anyone is trying to get this working, this did the trick for me:

    table.on('key-return-submit', function (e, datatable, cell) {
      cell.focus();
    });
    

    Now the KeyTable focus follows the cell when it's renamed, enter is pressed and it's resorted. It'd be nice if that happened automatically but this is an easy workaround. Tab seems to follow the row properly without any workarounds and while I'm not positive I'm guessing that might have been fixed with the Editor 2 release. The one other issue I've seen is the KeyTable focus doesn't follow the selected cell when you sort a column. I'm not sure if there's a way to listen for that event and then update the KeyTable focus manually.

This discussion has been closed.