问题
i try to create a primefaces datatable with fixed column width for some(not all) columns. The tableheader got 3 rows with colspan and rowspan. I want now to fix the width of the first column under "a". The second column should be dynamic.
Without Colspan i could use the width attribute of the Header Column element. But now i cant use the header column because it is for two columns. The width for the normal Column is ignored. (width="30" and style="width:30px;")
I added a screenshot of my Problem(http://s14.directupload.net/images/140717/z2a7vbrj.png). The first Table is correct and complete HTML(self written) the second Table is primefaces datatable seen in the following code snippet:
<p:dataTable var="produktkenntniss"
value="#{xyz}">
<p:columnGroup type="header">
<p:row>
<p:column rowspan="3" colspan="2"
headerText="a" />
<p:column colspan="2"
headerText="b" />
<p:column colspan="5"
headerText="c" />
<p:column rowspan="3"
headerText="d" />
</p:row>
<p:row>
<p:column rowspan="2"
headerText="e" />
<p:column rowspan="2"
headerText="f" />
<p:column colspan="2"
headerText="g" />
<p:column colspan="2"
headerText="h" />
<p:column headerText="i" />
</p:row>
<p:row>
<p:column
headerText="j" />
<p:column headerText="k" />
<p:column
headerText="l" />
<p:column headerText="m" />
</p:row>
</p:columnGroup>
<p:column width="30">
<h:outputText
value="n" />
</p:column>
<p:column>
<h:outputText
value="o" />
</p:column>
...
I hope someone can help me!
Best regards
Simon
回答1:
I am using PrimeFaces 5 and I'm having the same issue. I did not find the Primefaces way to solve this issue but you can use simple CSS styling in primefaces tags and it will work:
<p:columnGroup type="header">
<p:row>
<p:column rowspan="2" style="width:10%" headerText="a"></p:column>
<p:column rowspan="2" style="width:5%" headerText="c"></p:column>
<p:column rowspan="2" style="width:5%" headerText="c"></p:column>
The style attribute is recognized in the p:column tags within the columnGroup, and is rendered without modification by PrimeFaces.
In your case you have applied the style to the p:column tags which are not in the columnGroup.
All best,
Loic
回答2:
it is unsupported with scrollable datatable, have a look at (Datatable Scrollable with Grouping column width issue)
来源:https://stackoverflow.com/questions/24807411/primefaces-datatable-colspan-column-width-not-working