how to put the scroll top at the beginning of the table

how to put the scroll top at the beginning of the table

wtrujillodwtrujillod Posts: 1Questions: 1Answers: 0
edited September 6 in Scroller

Hi
I am loading an entire table from the server and displaying it in the view using Ajax in a Datatable
How can I do so that when I change to the next page the position the scroll returns to the beginning of the table and does not save the position of the row of the previous page
I have reviewed several posts on the site but i can't do it

My code:

var table_admin_equipos = $('#table_admin_equipos').DataTable( {
        language: datetable_languaje,
        autoWidth: true,
        scrollTop: true,
        scrollY: 200,
        scrollX: true,
        select: {
        style: 'single',
        selector: 'td:nth-child(1), td:nth-child(2), td:nth-child(3), td:nth-child(4)'
         },
        "columnDefs": [
        {
          "targets": [6,7,8,9,10],
          "visible": true,
          "sorting" : false,
          "searchable": false
        },
        {
          "targets": [0],
          "visible": false,
          "sorting" : false,
          "searchable": false
        },
        ],

        pageLength:25,


        preDrawCallback: function (settings) {
          var api = new $.fn.dataTable.Api(settings);
          var pagination = $(this)
          .closest('.dataTables_wrapper')
          .find('.dataTables_paginate');

          if (api.page.info().pages <= 1) {
            pagination.hide();
          }
          else {
            pagination.show();
          }

        }
    });

Please someone help me

Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

  • colincolin Posts: 12,877Questions: 0Answers: 2,198

    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

Sign In or Register to comment.