different behavior between 2.1.8 and 2.2.0 with border formatting on table

different behavior between 2.1.8 and 2.2.0 with border formatting on table

kdubskdubs Posts: 4Questions: 2Answers: 0

I've found a difference between 2.1.8 and 2.2.0 on treatment of tables with borders. With 2.1.8 the border appears to be accounted for and the horizontal scroll bar is not shown. It is show with 2.2.0. I believe the 2.1.8 behavior is correct.

I've provided the HTML to demonstrate the issue, and screen shots of the difference

<html lang="en">
  <head>
    <link rel="stylesheet" href="https://code.jquery.com/ui/1.14.1/themes/base/jquery-ui.css">
    <link rel="stylesheet" href="https://cdn.datatables.net/2.2.0/css/dataTables.dataTables.css">
    <style>
      #the_div { width:650px; }

      table, th, td {
          border: 1px solid black;
          border-collapse: collapse;
      }

    </style>

    <script src="https://code.jquery.com/jquery-3.7.1.js"></script>
    
    <!-- swap the order to see the difference -->

    <script src="https://cdn.datatables.net/2.2.0/js/dataTables.js"></script>
    <script src="https://cdn.datatables.net/2.1.8/js/dataTables.js"></script>

    <script>
      $(document).ready(function(){
      var tableId = 'example', table;
      const tab_obj = $('#' + tableId);
      
      const args = {
          autoWidth: true,
          scrollY: '800px',
              scrollX: true,
          scrollCollapse: true,
          scroller: true,
      };

      table = tab_obj.DataTable(args);
      });

    </script>
  </head>

  <body>
    <div id='the_div'>
      <table style='width:=100%' id='example'>
    <thead>
          <tr>
            <th>Firstname</th>
            <th>Lastname</th>
        <th>hidden</th>
            <th>Age</th>
          </tr>
    </thead>
    <tbody>
          <tr>
            <td>Priya</td>
            <td>Sharma</td>
        <th>hidden</th>
            <td>24</td>
          </tr>
    </tbody>
      </table>
    </div>
  </body>
</html>

2.2.0 output - notice scroll bar

2.1.8 output - no scroll bar

Answers

  • allanallan Posts: 63,761Questions: 1Answers: 10,510 Site admin

    Thanks for the test case. I'll try it when I'm in the office tomorrow morning. There is a fair chance that it might be related to this issue.

    Allan

  • allanallan Posts: 63,761Questions: 1Answers: 10,510 Site admin

    Turned out to be a different issue in the end. I've committed this fix which will be in 2.2.1 which I fully expect to release later today.

    Thanks again for the excellent test case!

    Allan

  • kdubskdubs Posts: 4Questions: 2Answers: 0

    and thanks for your very excellent utility!

  • kdubskdubs Posts: 4Questions: 2Answers: 0

    I tried the 2.2.1 release and the issue is fixed. thanks!

  • allanallan Posts: 63,761Questions: 1Answers: 10,510 Site admin

    Awesome - thanks for letting me know.

    Allan

Sign In or Register to comment.