I am trying to get the scrollTo plugin to work properly with what I am doing. When you click the green plus sign button on the table it opens up a div I am trying to have the scroll automatically scroll to show the div so that further down on the list you will automatically see the details instead of having them hidden like they are currently. Will someone please help assist me in this? I had this working with the dataTables scroller but that plugin was breaking all the other functions that I needed.
https://jsfiddle.net/nnb97rh9/7/
/* Formatting function for row details - modify as you need */
function format ( d ) {
// `d` is the original data object for the row
return '<div class="slider">'+
'<table cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;">'+
'<tr>'+
'<td>Full name:</td>'+
'<td>'+d.name+'</td>'+
'</tr>'+
'<tr>'+
'<td>Extension number:</td>'+
'<td>'+d.extn+'</td>'+
'</tr>'+
'<tr>'+
'<td>Extra info:</td>'+
'<td>And any further details here (images etc)...</td>'+
'</tr>'+
'</table>'+
'</div>';
}
$(document).ready(function() {
var table = $('#example').DataTable( {
"ajax": 'https://api.myjson.com/bins/16lp6',
scrollY: 250,
deferRender: true,
scroller: true,
scrollCollapse: true,
"columns": [
{
"class": 'details-control',
"orderable": false,
"data": null,
"defaultContent": ''
},
{ "data": "name" },
{ "data": "position" },
{ "data": "office" },
{ "data": "salary" },
{ "data": "extn", "visible": false }
],
"order": [[1, 'asc']]
} );
// Add event listener for opening and closing details
$('table.display').on('click', 'tr', function() {
var tr = $(this).closest('tr');
var row = table.row( tr );
var i = $(this).index();
var target = $("table.display tr").eq( tr.index() );
var duration = 300;
if ( row.child.isShown() ) {
// This row is already open - close it
$('div.slider', row.child()).slideUp( function () {
row.child.hide();
tr.removeClass('shown');
} );
}
else {
// Open this row
row.child( format(row.data()), 'no-padding' ).show();
tr.addClass('shown');
$('div.slider', row.child()).slideDown();
$('div.slider').scrollTo(target, duration);
}
} );
} );
[![enter image description here][1]][1]