dataTable: given column width not used when having frozenColumns
See original GitHub issueDescribe the bug
I have a fixed column but the fixed column does not consider the given column width of 120px. Instead of the given column width of 120px, it uses a width of 50% of parent container:
<p:dataTable scrollable="true" scrollHeight="640" scrollWidth="500" frozenColumns="1" ..>
<!-- width is not 120px but 50% of parent container >
<p:column width="120px">
..
</p:column>
</p:dataTable>
Looking at the pf components.css:
.ui-datatable table {
border-collapse: collapse;
width: 100%;
table-layout: fixed;
}
changing to
.ui-datatable table {
border-collapse: collapse;
width: auto;
table-layout: fixed;
}
will consider the given width of 120px but then when scrolling to the right, the column header does not start and begin with its column content.
Reproducer
No response
Expected behavior
Given p:column width must be considered.
PrimeFaces edition
None
PrimeFaces version
12
Theme
No response
JSF implementation
Mojarra
JSF version
2.3
Java version
jdk 17
Browser(s)
Firefox 107
Issue Analytics
- State:
- Created 9 months ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Frozen columns width · Issue #708 · primefaces ... - GitHub
When we use the datatable frozen columns, the table is automatically separated into width 50% to each side, a frozen and thawed other....
Read more >Set width of a frozen column - css - Stack Overflow
In order to change the width of the frozen columns, use the following CSS class: /* Change frozen width */ .ui-datatable-frozenlayout-left ...
Read more >Column width not working — DataTables forums
The widths given are then applied to that table and the actual widths are read back from it. It does this to try...
Read more >FrozenDataTable | PrimeFaces JavaScript API Docs
DOM element of the hidden input that holds the row keys of the rows that are expanded. Used to preserve the expansion state...
Read more >Table | Overview | JET Developer Cookbook - Oracle
Simple Table with Javascript Array data configured to support the following features: High-Water Mark scrolling; Sorting; Selection; Column resize/reorder ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Yep a lot of them across PF allow you to use “100px” or “100%” or “100vw”. Whatever is typically available as CSS!
Yes, we can give the unit indeed. This is something which I did not know. When giving the unit as percentage the above case works without using setting width in
.ui-datatable-frozenlayout-left. So I will close this issue. @melloware Thanks!