How to go to first record on datatable when fixed column and pagination is used?

How to go to first record on datatable when fixed column and pagination is used?

ekbordoekbordo Posts: 12Questions: 8Answers: 0
edited October 2018 in Free community support

Hello everyone;

I used pagination and fixed column in datatable. I would like to go to first record in the table when click to pagination button. Actually, without fixed columns, it works properly in below code. But when i use fixed column, it does not work. It scrolls outer one, not the inner(in datatable frame) scroll. Any idea?

Here my code:

 var oldStart = 0;
"fnDrawCallback": function (o) {
                if (o._iDisplayStart != oldStart) {
                    var targetOffset = $('#exampleTable').offset().top;
                    $('html,body').animate({ scrollTop: targetOffset }, 500);
                    oldStart = o._iDisplayStart;
                }

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,678Questions: 1Answers: 10,497 Site admin
    Answer ✓

    When scrolling is enabled, the table is split into three components (or two if there is no footer). So you need to scroll the DataTables scrolling container. You can do that with:

    $('div.dataTables_scrollBody').scrollTop( 0 );
    

    Allan

  • ekbordoekbordo Posts: 12Questions: 8Answers: 0

    thank you very much Allan. You save my life.

This discussion has been closed.