title: jQuery Datatables prevent scroller reset on table reload
body: <p>I finally got my datatable to reload on intervals. But what I'm noticing now is if you scrolled to the right, the table reload will reset the scroll back to the left. The same if you are scrolled down, it will reset back to the top.</p>
  
  <p>I need to stop this from happening.</p>
  
  <p>I've tried all the answers from this post:  <a href="https://stackoverflow.com/questions/27663743/how-to-maintain-jquery-datatables-scroll-position-after-draw">How to maintain jQuery DataTables scroll position after .draw()</a></p>
  
  <p>Nothing seems to work.  Maybe I'm missing something.  </p>
  
  <p>I noticed on this post, the question is using a datatables.scroller.min.js:  <a href="https://stackoverflow.com/questions/13644170/datatables-save-state-scroll-position">DataTables save state scroll position</a></p>
  
  <p>This led me to this:  <a href="https://cdn.datatables.net/scroller/1.4.2/" rel="nofollow noreferrer">https://cdn.datatables.net/scroller/1.4.2/</a></p>
  
  <p>But there are so many CSS files there.  I'm not sure which one to use, if any should be used at all.</p>
  
  <p>Maybe I do not need any of the above, and I just need to adjust my code below to prevent the scroll reset from happening:</p>
  
  <p>Click event:</p>
  
  <pre><code>$('.searchSubmit').on('click', function() {
    updateDataTable();
  
    var idle = 0;
    var idleInterval = setInterval(timer, 5000);
    $(this).mousemove(function(e){idle = 0;});
    $(this).keypress(function(e){idle = 0;});
    function timer()
    {
      idle = idle + 1;
      if(idle &gt; 2)
      {
        updateDataTable();
        console.log('table reloaded'); 
      }
    }
  });
  </code></pre>
  
  <p>Datatable:</p>
  
  <pre><code>function updateDataTable() {
    $.ajax({
      url: 'api/railmbs.php',
      type: 'POST',
      data: data,
      dataType: 'html',
      success: function(data, textStatus, jqXHR)
      {
        var jsonObject = $.parseJSON(data); 
        var table = $('#example1').DataTable({    
          "data": jsonObject,
          "columns": [
            { "data": "BILL" },   
            { "data": "CONTAINER" },
            // few more columns
          ],
          "iDisplayLength": 25,
          "paging": true,
          "scrollY": 550,
          "scrollX": true,
          "bDestroy": true,
          "stateSave": true,  
          "autoWidth": true
        });
      },
      error: function(jqHHR, textStatus, errorThrown)
      {
        console.log('fail');
      }
    });
  }
  </code></pre>