KeyTable error after Pg-Dn

KeyTable error after Pg-Dn

AntanasJAntanasJ Posts: 1Questions: 1Answers: 0

Hello,
I first steps trying DataTble. All is nice, but have small problem if:
1. On server is 15 records,
2. After load, first page display 10 records.
3. I set focus to cell in 8-th row.
4. After pressing Pg-Down, my Chrome display error:
dataTables.keyTable.js:603 Uncaught TypeError: Cannot read property 'top' of undefined

May be the problem is that 2 page have only 5 lines ?

table cofiguration like this:

$('#grafitas').DataTable( {
serverSide: true,
pageLength: 10,
ajax: { url: "/app/datatables?table=......"
},
keys: {columns: ":not(.freeze)"
},
columns: [...]
} );

Thanks for any answer
Antanas

Answers

  • rgriffithrgriffith Posts: 9Questions: 1Answers: 0

    I am running into a similar error where selecting a cell and paginating from a page with say 10 rows to a page with less than 10 rows throws an error. My setup is also server-side.

    The specific code causing the issue is at dataTables.keyTable.js#L469-L496. In this case, cell coming from _focus is empty. A quick fix could be to simply return if cell is empty before attempting to focus on it, or just focus the first or last cell instead.

  • allanallan Posts: 63,679Questions: 1Answers: 10,498 Site admin

    Could you try the nightly version of KeyTable please?

    Thanks!
    Allan

  • rgriffithrgriffith Posts: 9Questions: 1Answers: 0

    Confirmed the error still occurs in the nightly version as well.

  • allanallan Posts: 63,679Questions: 1Answers: 10,498 Site admin

    I've committed a fix for this now. The nightly version will rebuild shortly (within 10 minutes) and include that change.

    Thanks for checking it out and letting me know about this issue.

    Allan

  • rgriffithrgriffith Posts: 9Questions: 1Answers: 0

    Thank you for looking into this, Allan.

    Curious, but in my case I was running into the error when using DataTable's pagination controls, not keyboard shortcuts. Will this change also address my issue? I will test shortly regardless and report back.

  • rgriffithrgriffith Posts: 9Questions: 1Answers: 0
    edited November 2016

    Confirmed, the error is not triggered when using the Page Down key; however, it is still present if you simply use the DataTables pagination controls.

    I might be wrong, but I feel like the fix may need to be somewhere within the focus/scroll methods so it can handle both cases.

  • allanallan Posts: 63,679Questions: 1Answers: 10,498 Site admin

    Yes - I haven't considered the paging controls as well. Doh. I'll look into that and post back when done.

    Allan

  • rgriffithrgriffith Posts: 9Questions: 1Answers: 0

    Awesome, thanks Allan!

  • allanallan Posts: 63,679Questions: 1Answers: 10,498 Site admin

    Fix committed. It should all be right this time! I've also modified the client-side processing behaviour to match the server-side now, which has the nice benefit of actually simplifying some aspects.

    The nightly will be up-to-date shortly.

    Regards,
    Allan

  • rgriffithrgriffith Posts: 9Questions: 1Answers: 0

    Hey Allan,

    Confirmed the error is indeed fixed, thanks again!

    Probably really minor and just needs getting used to, but the new behavior does feel a little odd at first. In my case:

    • Table with 22 rows, showing 10 rows at a time
    • Simulate row focus by only allowing focus on first cell in the rows
    • Focus last row on first page, paginate to the last page
    • "Last cell" on the page gets focus, makes sense
    • Paginate back one, the second row gets focus, because that's technically what was focused on the last page

    For comparison, I was testing Gmail and noticed they just focus the first row on pagination regardless of what you had focused previously.

  • allanallan Posts: 63,679Questions: 1Answers: 10,498 Site admin

    For tables with a low number of pages, yes I can see that it might not always flow immediately. For tables with larger data sets, I think this approach works well.

    Having said that, I'm very much willing to take feedback on this interaction, and as more comes in I might update the software in future!

    Regards,
    Allan

  • rgriffithrgriffith Posts: 9Questions: 1Answers: 0

    That does make sense, Allan.

    Any thoughts on when 2.2.0 will make it? We're using bower in our project so I'll need to eventually bump the version for this fix.

    Thanks again for the help!

  • allanallan Posts: 63,679Questions: 1Answers: 10,498 Site admin

    Not sure. Possibly early December alongside Editor 1.6, or possibly before. If I release DataTables 1.10.13 before Editor 1.6 it will be then. It depends how quickly the 1.6 development goes...!

    Allan

  • rgriffithrgriffith Posts: 9Questions: 1Answers: 0

    Sounds good, thank you again for the help Allan!

This discussion has been closed.