簡體   English   中英

如何在PrimeFaces中更改面板網格的列寬

[英]How can I change column width of panel grid in PrimeFaces

我正在使用Java EE和PrimeFaces。 如何在PrimeFaces中更改面板網格的列寬? 有一個例子嗎?

您可以使用columnClasses在panelGrid中限定列。 以下代碼設置不同的寬度,並將單元格內容與頂部對齊。

<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;
}

我有類似的問題,這是我的解決方案:

<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>

如您所見,主要區別在於您沒有p:panelGrid中定義columns屬性。 在頁眉和頁腳中你必須使用p:rowp:列 ,在我的情況下我還必須使用colspan = 2,因為在正文中我們有2列。

希望這可以幫助 ;)

你考慮過style屬性了嗎? 示例:

<p:panelGrid columns="2" style="width: 50px">

否則,對於列:

<p:column style="width:50px">

請參閱此主題: 如何在<p:panelGrid>中調整<p:column>的寬度?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM