ScrollY position to Top when change page

ScrollY position to Top when change page

GiuloGiulo Posts: 29Questions: 2Answers: 0

Hi,
I've st scrollY and when I select 100 rows for page correctly he shows me the scrollbar.

$(document).ready(function() {
    var table = $('#clienti').DataTable( {
        data: dataSet,
        responsive: true,
        "scrollY": scrollY + "px",
        "scrollCollapse": true, 
        "processing": true,         
        columns: [

My problem is when I move scroll for example in the middle and then I change page it keeps scrollbar position while I would like it to be positioned to Top.

I suppose that:

$(document).ready(function() {
    $('#clienti').on( 'page.dt', function () {alert('Do something on scrollbar'); });
} );

moreover if I try to use $.fn.dataTable.FixedHeader and move the scrollbar and change page I create a double header at the beginning of my web page, unless you first place the scrollbar by hand to top before changing page!

Sorry for my english

Replies

  • colincolin Posts: 3,648Questions: 0Answers: 645

    Hi @Giulo ,

    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

  • GiuloGiulo Posts: 29Questions: 2Answers: 0
    edited January 9

    Hi @Colin,
    Thanks for your quick response but I can't do a test case, I think I write wrong but my request is only if it possible to set scrollY position on Top by and datatable event where I enable "scrollY" option.

    Test case is to do a datatable with pagination and number rows selector and then?

    P.S. Ignore my consideration of $.fn.dataTable.FixedHeader that I've removed some days ago

  • GiuloGiulo Posts: 29Questions: 2Answers: 0

    I don't know if it's correct but my workaround is:

    $(document).ready(function() {
        $('#example').on( 'page.dt', function () {$('.dataTables_scrollBody').scrollTop(0);});
    } );    
    
  • colincolin Posts: 3,648Questions: 0Answers: 645

    As I always say, if it works, that's a good sign - glad all working :)

Sign In or Register to comment.