Scroller is scrolling to wrong row

Scroller is scrolling to wrong row

tjodtjod Posts: 3Questions: 2Answers: 0

My table has 45000 rows. If I scroll to row 44500 it works fine. 44600 or 44700 scroll to wrong row, yet 44800 works fine.
Here is self-contained example html/js code that should show the problem when you enter these row numbers. I'm using Chrome Version 75.0.3770.100 (Official Build) (64-bit) and also Safari Version 12.1.1 (14607.2.6.1.1)

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>DataTables scroll test</title>
    
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
    <script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
    <script src="https://cdn.datatables.net/scroller/2.0.0/js/dataTables.scroller.min.js"></script>
    
    <link href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css" rel="stylesheet" type="text/css"/>
    <link href="https://cdn.datatables.net/scroller/2.0.0/css/scroller.dataTables.min.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<h3>
    Table has 45000 rows.  Scroll to row 44500 works fine.  44600 or 44700 scroll to wrong row, yet 44800 works fine.
</h3>
    <button>Scroll</button> to row
    <input id="row" type="number" style="width:60px;" value=44600 />
    <div>
        <table id="data_table" class="cell-border">
        </table>
    </div>
</body>
<script>
$(function () {
    var rows = [];
    for (var i=0; i < 45000; ++i) {
            rows.push( {row_index: i, alogp: (10.*Math.random()-5.0).toFixed(2)} );
    };
    var columns = [
        {name: "row_index", title: "row_index", data:"row_index"},
        {name: "alogp", title: "alogP", data:"alogp"}
    ];
    var dt = $("#data_table").DataTable({
        data: rows,
        columns: columns,
        scroller: true,
        scrollY: 400,
        scrollX: 200
    });
    $("button").click( function(event) { 
        var row = $("#row").val();
        //dt.scroller.measure(); // has no effect on mis-scrolling to 44600
        dt.row(row).scrollTo(false);
    });
});
</script>
</html>

This question has accepted answers - jump to:

Answers

  • colincolin Posts: 15,166Questions: 1Answers: 2,588
    Answer ✓

    Hi @tjod ,

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • tjodtjod Posts: 3Questions: 2Answers: 0

    Here is a link to a running example, using the code quoted in my message.
    http://live.datatables.net/lenatehe/1/edit

  • allanallan Posts: 61,863Questions: 1Answers: 10,136 Site admin
    Answer ✓

    Interesting. Thanks for posting this. I've created a bug for this to make sure I look at it before the next Scroller release.

    Allan

  • allanallan Posts: 61,863Questions: 1Answers: 10,136 Site admin

    I believe I've corrected the issue with this commit. It appears to be operating in our auto tests and a bunch of manual ones I've just tried. Colin will be able to confirm if he's happy with it :).

    Allan

  • colincolin Posts: 15,166Questions: 1Answers: 2,588

    Yep, all good now. You can find the nightly releases here, or the release will be made in the next couple of days.

This discussion has been closed.