admin管理员组文章数量:1415653
I have a dataTable with infinite scrolling. I want to scroll to a selected row on table refresh
$('#table1').dataTable({
'aaData': data,
'aoColumns': columns,
'bInfiniteScroll': true,
'bColumnCollapse': true,
'sScrollY': '200px'
});
$('#btnScroll').click(function(){
$('.dataTables_scrollBody').scrollTo($('#table1 tbody tr').eq(3), 800);
});
But it does not scroll to the row
I have a dataTable with infinite scrolling. I want to scroll to a selected row on table refresh
$('#table1').dataTable({
'aaData': data,
'aoColumns': columns,
'bInfiniteScroll': true,
'bColumnCollapse': true,
'sScrollY': '200px'
});
$('#btnScroll').click(function(){
$('.dataTables_scrollBody').scrollTo($('#table1 tbody tr').eq(3), 800);
});
But it does not scroll to the row
Share Improve this question asked Jul 14, 2014 at 7:05 user544079user544079 16.6k42 gold badges120 silver badges172 bronze badges2 Answers
Reset to default 2You can use animate to scroll to your position
$('.dataTables_scrollBody').animate({
scrollTop: $('#table1 tbody tr').eq(3).offset().top
}, 800)
DEMO
You are using the scrollTo plugin. Have you loaded it? You can write this without that plugin as follows:
var selectedRow = $('#table1 tbody tr').eq(3);
$('.dataTables_scrollBody').scrollTop(selectedRow.prop('offsetTop') - $('.dataTables_scrollBody').height()/2);
本文标签: javascriptScroll to selected row in DataTables jQuery pluginStack Overflow
版权声明:本文标题:javascript - Scroll to selected row in DataTables jQuery plugin - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745165580a2645655.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论