Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Datatables - fixedHeader with scrollX

Tags:

datatables

I am trying to use Datatables with fixedheader (v3) as well as enable horizontal scrolling. Attached is the fiddle http://jsfiddle.net/xF8hZ/344/

$(document).ready(function() {
    var table = $('#example').DataTable({        
       searching: false,
        paging: false,
        ordering: false,
        info: false,
        fixedHeader: true,
        scrollX: true
    });

} );

.

When scrolling the fixedheader width doesn't align with the rest of the table. Can you help me solve this please?

Thanks

like image 569
user3377206 Avatar asked Jun 12 '26 05:06

user3377206


1 Answers

Pure css solution using css sticky (not work in ie 11): remove the fixHeader plugin add this css

.dataTables_scrollHead {
  position: sticky !important;
  top: 119px;
  z-index: 99;
  background-color: white;
  box-shadow: 0px 5px 5px 0px rgba(82, 63, 105, 0.08);
}
like image 73
thành tùng Avatar answered Jun 17 '26 17:06

thành tùng



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!