Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dataTable column widths change with number of characters in header #967

Closed
joepal1976 opened this issue Jul 12, 2018 · 2 comments
Closed

Comments

@joepal1976
Copy link

Expected: columns should be equally wide, unless content overflows.

Actual: A column with the label "1234567890" is wider than a column with the label "12345" despite there being plenty of space.

There seems to be a linear relation, but a column with the label "1" is not ten percent of the width of "1234567890".

colwidth

Debugging this, it seems there is an "autowidth" feature of datatables: https://datatables.net/reference/option/autoWidth. However, toggling this (custom-options="autoWidth:false") does not seem to have any effect.

This is a minor glitch since it's possible to set explicit widths on columns (via custom-option on dataTableColumn), but it's a confusing behavior when first encountered.

@stephanrauh
Copy link
Collaborator

After some Googling, I start to believe that autoWidth is a broken feature. I've found an alternative to setting the width on the individual columns:

<b:dataTable value="#{carPool.carPool}"
                     var="car"
                     custom-options="'aoColumns': [{'sWidth':'16%'},{'sWidth':'16%'},{'sWidth':'16%'},{'sWidth':'16%'},{'sWidth':'16%'},{'sWidth':'16%'}]">

But I don't think that's an improvement :).

Also see https://datatables.net/forums/discussion/41870/column-width-not-working (and scroll to the latest answer).

In 2010, the feature wasn't broken, at least according to this article: http://www.craiglotter.co.za/2010/08/16/jquery-datatables-how-to-force-specific-column-widths/

@stephanrauh
Copy link
Collaborator

Also see #957.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants