Issue with scrollX and tables of unknown width
Issue with scrollX and tables of unknown width
Hello there,
I'm Marco and I'm having an issue with DataTables 1.10.13.
I have to create a generic library to handle tables that will be built at runtime. I don't know how many columns tables will have and how large will the table container be, so I thought that enabling scrollX by default could be a wise choice.
The problem is that if the table doesn't require the scrollX, the header will end up being misaligned, as shown in this fiddle:
https://jsfiddle.net/DT84/xxkgxr48/
Is it a bug of DataTable or is it designed in way that scrollX should be enabled only when it's really needed?
Is there a workaround to make scrollX work even on "narrow" tables?
Thanks in advance.
Cheers.
Marco
This question has an accepted answers - jump to answer
Answers
Looks like all you need to do is add width="100%" to your tables:
<table id="table02" width="100%">
Kevin
Adding a simple width="100%" made the trick, I can't thank you enough!
Marco