【问题标题】:JQuery TableSorter 2.25 (Mottie fork) w/ Scroller: Programmatically scroll to row?JQuery TableSorter 2.25(Mottie fork)w/Scroller:以编程方式滚动到行?
【发布时间】:2016-01-20 16:37:07
【问题描述】:

我已经使用Mottie fork of the JQuery TableSorter 插件有一段时间了,它非常棒。我正在使用"scroller" widget 使表格可以垂直和水平滚动,同时在左侧保留一些固定列。

问题来了:有没有办法以编程方式滚动到特定行?例如“myTable.scrollToRow(40)”?像素偏移也是完全可以接受的。

【问题讨论】:

    标签: jquery tablesorter


    【解决方案1】:

    我不确定使用什么界面来允许用户滚动到特定行,但是您可以使用以下代码来设置滚动 (demo):

    HTML(用于演示)

    Scroll to row: <button type="button">20</button> <button type="button">40</button>
    

    脚本

    $('button').click(function(){
        var $scroller = $('.tablesorter-scroller-table'),
        row = parseInt( $(this).text(), 10 ),
        position = $table.find('tbody tr').eq(row).position();
      $scroller.scrollTop( $scroller.scrollTop() + position.top );
    });
    

    【讨论】:

    • 这个技巧非常好,即使使用固定列!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-09-01
    • 2018-03-03
    • 2011-01-16
    • 2011-01-15
    • 2010-11-13
    • 2014-05-22
    • 2013-07-09
    相关资源
    最近更新 更多