KeyTable error after Pg-Dn
KeyTable error after Pg-Dn
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
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 ifcell
is empty before attempting to focus on it, or just focus the first or last cell instead.Could you try the nightly version of KeyTable please?
Thanks!
Allan
Confirmed the error still occurs in the nightly version as well.
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
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.
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.
Yes - I haven't considered the paging controls as well. Doh. I'll look into that and post back when done.
Allan
Awesome, thanks Allan!
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
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:
For comparison, I was testing Gmail and noticed they just focus the first row on pagination regardless of what you had focused previously.
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
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!
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
Sounds good, thank you again for the help Allan!