title: How to maintain jQuery DataTables scroll position after .draw()
body: <p>I am using jQuery Datatables plugin for a smal table (12 rows). Some <code>&lt;input type="text" ...</code> fields allow editing. When the input field loses focus I need to validate its value and possibly change the field value. I haven't been able to get modified input field values to be recognized by DataTables without issuing a <code>.draw()</code> afterwards, but this causes the table to scroll to the top of the table.</p>
  
  <p>Is there a way of maintaining the current scroll position after issuing a .draw()?</p>
  
  <pre><code>$('#mytable').on('blur', 'input', function (e) {
  
      var inputFieldId = this.id;
      var inputFieldVal = $(this).val();
  
      { ... perform validation of field value ... }
  
      $('#mytable').DataTable().rows().invalidate().draw();
  });
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>I saw someone trying to do the same thing I am and they indicated that the following code worked for them. This seems like a very simple way of accomplishing what I need, but I'm always getting scrollTop = 0 myself. Anyone see how I can get the row index of the currently selected row?</p>
  
  <pre><code>var scrollPos = $(".dataTables_scrollBody").scrollTop();
  $('#mytable').DataTable().rows().invalidate().draw(false);
  $(".dataTables_scrollBody").scrollTop(scrollPos);
  </code></pre>