I am using jQuery Datatables and I want to know how to automatically scroll to show the details-control when it is pressed. If I click the last row of my table it will open the information but the user will never know to scroll down. Is it possible to have it automatically scroll to show the details when using details-control?
When the green plus sign is chosen it appears as so:

After you manually scroll it then appears:

Is it possible to have it automatically scroll for the user to see easier than having to manually scroll?
var someTable = $('#processing1').DataTable( {
"columns": [
{
"class": "details-control1",
"orderable": false,
"data": null,
"defaultContent": ""
},
{ "data": "id" },
{ "data": "dealerID" },
{ "data": "Date_Received" },
{ "data": "op_id" },
{ "data": "Date_Due" },
{
"data": "Date_Complete",
"render": function(data){
return ((data) ? "COMPLETED" : "PROCESSING");
}
},
{ "data": "Completed_Late" },
{ "data": "Closed_by" },
{ "data": "Rmks" },
{ "data": "Processing_Location" },
{ "data": "Item_Count" }
],
"order": [[1, 'asc']],
"columnDefs": [
{ "targets": [0,2,3,4,5,6,7,8,9,10,11], "searchable": false }
],
"sDom": '<"row view-filter"<"col-sm-12"<"pull-left"l><"pull-right"f><"clearfix">>>t<"row view-pager"<"col-sm-12"<"text-center"ip>>>',
select: {
style: 'single'
},
scrollY: 250,
deferRender: true,
scroller: true,
"aLengthMenu": [[25, 50, 75, -1], [25, 50, 75, "All"]],
"iDisplayLength": 25,
"oLanguage": {
"sLengthMenu": "_MENU_ <label for='processing1_length'><strong>records per page</strong></label>",
"oPaginate": {
"sPrevious": "«",
"sNext": "»",
}
}
});
// Array to track the ids of the details displayed rows
var somedetailRows = [];
$('#processing1 tbody').on( 'click', 'tr td.details-control1', function () {
var tr = $(this).closest('tr');
var row = someTable.row( tr );
var idx = $.inArray( tr.attr('id'), somedetailRows );
if ( row.child.isShown() ) {
tr.removeClass( 'details1' );
row.child.hide();
// Remove from the 'open' array
somedetailRows.splice( idx, 1 );
}
else {
tr.addClass( 'details1' );
row.child( format( row.data() ) ).show();
// Add to the 'open' array
if ( idx === -1 ) {
somedetailRows.push( tr.attr('id') );
}
}
});
// On each draw, loop over the `somedetailRows` array and show any child rows
someTable.on( 'draw', function () {
$.each( somedetailRows, function ( i, id ) {
$('#'+id+' td.details-control1').trigger( 'click' );
});
});
I have added this plugin: https://github.com/flesler/jquery.scrollTo
but cannot figure out where to insert this code and what to replace object with.
var scroller = oTable.fnSettings().nTable.parentNode;
$(scroller).scrollTo( object, 1 );
What does object need to be changed to?
EDIT
$('#processing1 tbody').on( 'click', 'tr td.details-control1', function () {
var tr = $(this).closest('tr');
var row = someTable.row( tr );
var i = $(this).index() ;
var idx = $.inArray( tr.attr('id'), somedetailRows );
if ( row.child.isShown() ) {
tr.removeClass( 'details1' );
row.child.hide();
// Remove from the 'open' array
somedetailRows.splice( idx, 1 );
}
else {
tr.addClass( 'details1' );
row.child( format( row.data() ) ).show();
// Add to the 'open' array
if ( idx === -1 ) {
somedetailRows.push( tr.attr('id') );
someTable.scroller().scrollToRow(i + 2);
}
}
});
scrollTojQuery library. github.com/flesler/jquery.scrollToobjectvalue can be replaced with anything you want to target (or scrollTo). Check out the documentation for the plugin to see all the options you have. You can target offsets, DOM elements, jQuery objects, etc.