Scroller and KeyTable issue

Scroller and KeyTable issue

adam@cuskit.co.ukadam@cuskit.co.uk Posts: 7Questions: 3Answers: 0

If you use both Scroller and KeyTable together and use the arrow keys to navigate around the grid when you get to the end of the current page the keyboard navigation goes wrong.

I've created a jsfiddle here based on the Scroller Server Side Processing example only with the Keytable plugin added.

If you run that and select a cell, then keep pressing the down arrow. Once Scroller starts changing the data the focus starts jumping around all over the place.

I believe the currently selected cell is held based on an index that isn't reset when the data displayed is changed.

Answers

  • allanallan Posts: 61,431Questions: 1Answers: 10,048 Site admin

    I believe the currently selected cell is held based on an index that isn't reset when the data displayed is changed.

    That is exactly correct. There was a change a little while back to make client and server-side processing behave the same with KeyTable - that is to retain the current position when changing page. That's useful is most cases, but distinctly unhelpful in this case!

    I'll have a think about what we can do about that - I'm not immediately sure to be honest.

    Allan

  • adam@cuskit.co.ukadam@cuskit.co.uk Posts: 7Questions: 3Answers: 0

    I'll admit I don't know the source code for these plugins at all but I would assume that after loading the next page Scroller would know how far the row indexes have changed as it is able to draw the new rows in the exact position of the old ones.

    So ideally if $.fn.dataTable.KeyTable exists it should look at the current focused cell, add/subtract the difference to the row index and call .cell().focus() on that cell.

  • allanallan Posts: 61,431Questions: 1Answers: 10,048 Site admin

    Part of the issue is that DataTables can reuse row indexes - particularly in server-side processing mode, so KeyTable is attempting to focus on a cell, but the wrong one, which is why it jumps around.

    There probably is a workaround, but I'm not yet certain what it should be I'm afraid.

    Allan

This discussion has been closed.