1

I've noticed that a lot of the issues on jquery data tables have to do with horizontal scrolling and misalignment of headers. My issue is different. I do not have horizontal scrolling, but my header doesn't align on page load. See image below.

enter image description here

It looks like each header varies based off of the length of text in the box. Before adding the fixed header, everything was aligned. Im wondering if anyone hasd experienced this and if so, how did you work around it?

1
  • Are you using the latest jQuery DataTables version? Commented Jul 26, 2016 at 16:13

3 Answers 3

1

See if calling fixedHeader.adjust() will solve it. For example:

$('#example').DataTable({
   'drawCallback': function( settings ) {
      var api = this.api();
      api.fixedHeader.adjust();
   }
});

It looks like you're displaying custom controls in the table and they may be initialized after jQuery DataTables calculates width of headings.

Sign up to request clarification or add additional context in comments.

2 Comments

cannot ready property adjust of undefined, i dont think that function is in my js
@Monzingo, FixedHeader extension 3.0 is required, make sure you the latest files.
0

I was able to fix this by downloading the package through NPM and then applying the fixedHeader attribute to true on tale initialization

Comments

0

Write,

$(".dataTables_scrollBody").width($(".dataTables_scrollHead").width());

Note:- I hope you have written "scrollX": true If not then please write this line. It will enable horizontal scrollbar.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.