Note that there are some explanatory texts on larger screens.

plurals
  1. POTwo DataTables in one page - how to scroll just one of the tables?
    primarykey
    data
    text
    <p>I have two DataTables in one page initialized as follows:</p> <pre><code> //First table sListTable = $('#subListTable').dataTable({ "sScrollY": "265px", "sDom": "frtiS", "bDeferRender": true, "aaSorting": [[ 1, "desc" ]], "aoColumnDefs": [ {"sType": "date", "aTargets": [1]} ] }); //Second table pListTable = $('#projListTable').dataTable({ "sScrollY": "265px", "sDom": "frtiS", "bDeferRender": true, "aaSorting": [[ 1, "desc" ]], "aoColumnDefs": [ {"sType": "date", "aTargets": [1]} ] }); </code></pre> <p>As you can see, I'm using a separate variable for each table and each table has it's own unique ID.</p> <p>Now I have a function that automatically highlights a row in the "projListTable" table and scrolls that row into view based on some event: </p> <pre><code>//Auto-scroll to row with 'row_selected' class var container = $('#projListTable,div.dataTables_scrollBody'); var scrollTo = $('#projListTable tbody tr.row_selected'); container.scrollTop(scrollTo.offset().top - container.offset().top); </code></pre> <p>This auto-scrolling script is working fine, BUT the problem is that it also scrolls the other table (sListTable) even though "projListTable" is specifically specified as shown above.</p> <p>What do I need to do, such that only "projListTable" is the only one affected by the the container.scrollTop() call? I have a feeling it's because they share "div.dataTables_scrollBody", but I can't figure out how to get around with it. Any help is much appreciated. </p> <p>Here's the code in action showing the problem:</p> <p><a href="http://live.datatables.net/ekatik/8" rel="nofollow">http://live.datatables.net/ekatik/8</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload