[英]How can I change column width of panel grid in PrimeFaces
I am working with Java EE and PrimeFaces. 我正在使用Java EE和PrimeFaces。 How can I change the column width of a panel grid in PrimeFaces?
如何在PrimeFaces中更改面板网格的列宽? Is there an example ?
有一个例子吗?
You can qualify your columns inside the panelGrid using columnClasses. 您可以使用columnClasses在panelGrid中限定列。 The following code sets different width and stick the cells content aligned to the top-side.
以下代码设置不同的宽度,并将单元格内容与顶部对齐。
<h:panelGrid columns="2" style="width: 100%" columnClasses="forty-percent top-alignment, sixty-percent top-alignment">
.forty-percent {
width: 40%;
}
.sixty-percent {
width: 60%;
}
.top-alignment {
vertical-align: top;
}
I had a similar problem and here is my solution: 我有类似的问题,这是我的解决方案:
<p:panelGrid style="width:100%"> # notice that I do not define columns attribute in p:panelGrid!!
<f:facet name="header"> # header
<p:row> # p:row and p:column are obligatory to use since we do not define columns attribute!
<p:column colspan="2"> # here I use colspan=2, coz I have 2 columns in the body
Title
</p:column>
</p:row>
</f:facet>
<p:row>
<p:column style="width:150px"> # define width of a column
Column 1 content
</p:column>
<p:column> # column 2 will fill the rest of the space
Column 2 content
</p:column>
</p:row>
<f:facet name="footer"> # similar as header
<p:row>
<p:column colspan="2">
Footer content
</p:column>
</p:row>
</f:facet>
</p:panelGrid>
So as you can see, the main difference is that you do not define columns attribute in p:panelGrid . 如您所见,主要区别在于您没有在p:panelGrid中定义columns属性。 In header and footer you have to use p:row and p:column , and in my case I also have to use colspan=2 since in body we have 2 columns.
在页眉和页脚中你必须使用p:row和p:列 ,在我的情况下我还必须使用colspan = 2,因为在正文中我们有2列。
Hope this helps ;) 希望这可以帮助 ;)
Have you considered the style attribute ? 你考虑过style属性了吗? Example :
示例:
<p:panelGrid columns="2" style="width: 50px">
Otherwise, for columns : 否则,对于列:
<p:column style="width:50px">
Refer to this thread : how can I adjust width of <p:column> in <p:panelGrid>? 请参阅此主题: 如何在<p:panelGrid>中调整<p:column>的宽度?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.