check checkboxes and select the rows in 1st table and row adjacent to 2nd table.

check checkboxes and select the rows in 1st table and row adjacent to 2nd table.

nikitha09nikitha09 Posts: 1Questions: 1Answers: 0

js file

$(document).ready(function() {
var table = $('#example').DataTable( {
scrollY: false,
scrollX: "100%",
scrollCollapse: true,
bPaginate : false,
dom: 'Bfrtip',
buttons: [

    {
        extend: 'pdf',

        exportOptions: {
            modifier: {
                selected: true
            }
        }
    }
    ],
    'columnDefs': [{
       'targets': 0,
       'searchable':false,
       'orderable':false,
       'className': 'select-checkbox novis',

       'render': function (data, type, full, meta){
        console.log("Data: " + data);

        return $(' <div/>').text(data).html();
    }}],
    'order': [1, 'asc'],
    fixedColumns:   {
        leftColumns: 1,
        rightColumns: 0
    }


} );

// $(".right-scroll").on('click', function() {
//     document.querySelector('.dataTables_scrollBody').scrollLeft += 40;
// }) 
// $(".left-scroll").on('click', function() {
//     document.querySelector('.dataTables_scrollBody').scrollLeft -= 40;
// }) 

/*$('.dataTables_scrollHeadInner tr th:first-child').addClass('staticCol');
$('#example tr').find('td:first-child').addClass('staticCol');
var abc  = $('.DTFC_LeftWrapper').html();
$(document).on('click',function() {
    $('.DTFC_LeftWrapper').html(abc);
    $('.DTFC_LeftWrapper').find('.staticCol').removeClass('staticCol');
});*/

var colIndex = 0, widths = [];
$('.dataTable thead th').each(function() {
    widths.push(parseInt(this.style.width)+25);
});

$(".right-scroll").on('click', function() {
    if (colIndex == widths.length-1) return;
    document.querySelector('.dataTables_scrollBody').scrollLeft += widths[colIndex];
    colIndex++;
}) ;
$(".left-scroll").on('click', function() {
    if (colIndex == 0) return;
    colIndex--;        
    var scrollLeft = 0;
    for (var i=0;i<colIndex;i++) { scrollLeft+=widths[i] }
        document.querySelector('.dataTables_scrollBody').scrollLeft = scrollLeft;
});
// $(".DTFC_LeftBodyWrapper tbody tr td.novis").on('click', function(){
//     console.log("DTFC_LeftBodyWrapper clicked");
// });

/*$('.DTFC_LeftBodyWrapper tbody tr td.novis').on('click', 'input[type="checkbox"]', function(e){
    e.stopPropagation();
    e.preventDefault();
    $(this).prop("checked",true);
    var $row = $(this).closest('tr');
    if(this.checked){
     $row.addClass('selected');
 } else {
     $row.removeClass('selected');
 }
 console.log(this);

});*/

$('#example_wrapper tbody').on( 'click', 'input[type="checkbox"]', function () {
var $row = $(this).closest('tr');
if(this.checked){
$row.addClass('selected');
} else {
$row.removeClass('selected');
}
} );

});

This discussion has been closed.