mardi 4 août 2015

jQuery DataTables - Responsive Table with ScrollY is not working

I am using DataTables plugin with Responsive Table and fixed yScroll and disabling xScroll.

But I am still getting the Horizontal Scrollbar, though I am adding the code like below...

scrollY: 200,
scrollX: false,

Anyhow, I am using Responsive table, why I want to show the Horizontal Scrollbar?

Please refer the code, online example and screenshot below...


Online Demo


CSS

th,td{white-space:nowrap;}

If I remove above css it is working as expected. But I dont want to wrap down the td / th text. This is where I am facing problem :(

jQuery:

$(document).ready(function() { 

  var table = $('#example').DataTable( {
    dom: 'RCT<"clear">lfrtip',

    scrollY: 200,
    scrollX: false,

    columnDefs: [
      { visible: false, targets: 1 }
    ],

    "tableTools": {
      "sRowSelect": "multi",
      "aButtons": [
        {
          "sExtends": "print",
          "sButtonText": "Print"
        }
      ]
    }

  });
});

HTML

<table id="example" class="display responsive" cellspacing="0" width="100%">
    <thead>
        <tr>
            <th>Name</th>
            <th>Position</th>
            <th>Office</th>
            <th>Age</th>
            <th>Start date</th>
            <th>Salary</th>
        </tr>
    </thead>

    <tbody>
        <tr>
            <td>Tiger Nixon</td>
            <td>System Architect</td>
            <td>Edinburgh</td>
            <td>61</td>
            <td>2011/04/25</td>
            <td>$320,800</td>
        </tr>
.....................

Screenshot Ref: enter image description here



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire