scroller plugin scroll table with keypress
scroller plugin scroll table with keypress
visceralist
Posts: 33Questions: 0Answers: 0
Hi
I asked this question elsewhere but I think it may have been too general. I am using the scroller plugin and I want to know how to scroll the table up/down using keyboward keydown event; i've got the events wired up, I just don't know the syntax for scroller API.
I tried doing this:
[code]
this.myTable.dataTable({
"sScrollY": "200px",
"sDom": "frtiS",
"bDeferRender": true,
"fnInitComplete": function () {
this.fnSettings().oScroller.fnScrollToRow(1000);
}
});
[/code]
but i get Cannot call method 'dataTable' of undefined error message with that. so basically I need to be able to hit arrow down on the page (without click inside the table first) and scroll down about 30px and scroll up when I hit the arrow up.
any info would help.
thanks
I asked this question elsewhere but I think it may have been too general. I am using the scroller plugin and I want to know how to scroll the table up/down using keyboward keydown event; i've got the events wired up, I just don't know the syntax for scroller API.
I tried doing this:
[code]
this.myTable.dataTable({
"sScrollY": "200px",
"sDom": "frtiS",
"bDeferRender": true,
"fnInitComplete": function () {
this.fnSettings().oScroller.fnScrollToRow(1000);
}
});
[/code]
but i get Cannot call method 'dataTable' of undefined error message with that. so basically I need to be able to hit arrow down on the page (without click inside the table first) and scroll down about 30px and scroll up when I hit the arrow up.
any info would help.
thanks
This discussion has been closed.
Replies
Can you show me a test page showing that error please? I don't understand why hat would be happening with the above code.
Allan
[code]
this.tableAccounts.dataTable({
"sScrollY": "400px",
"aaData": tableData,
"sDom": "tiS",
"bDeferRender": true...
[/code]
and I am sorry man, I know this would have been a lot simpler if I could link a page but its behind the damn firewall. :(
http://jsfiddle.net/visceral/Qymnv/1/
"aaData": tableData, is where data coming from the db.
[code]
$(document).bind('keydown', function (event) {
PageDown) {
$(".dataTables_scrollBody").scrollTop(200);
}
});
[/code]
(second line).
Have a look at this Fiddle http://jsfiddle.net/CN4UZ/5/ - original source: http://stackoverflow.com/questions/8681162/intercept-pageup-pagedown-keydown-events-in-chrome-browser .
Allan
[code]
$(document).bind('keydown', function (event) {
if (event.keyCode === KeyCodes.PageDown) {
$(".dataTables_scrollBody").scrollTop(50);
}
});
[/code]
with that I don't see any console errors; it scrolls the page down quickly and goes back to the top of the table. I added event.stoppropogation(); right after where I am calling the scrollTop(), but that didn't do much either.
I would also say, imho, that intercepting the page up / down button and having them do something that the user isn't expecting is a fairly bad idea. More or less no other page on the web does that, so they won't realise what is going on until they think about it.
cheers mate, you've been quite helpful.