2014-03-27 53 views
0

我想爲數據表中的cxolumns設置固定寬度 我試過 不同寬度的所有列。 但寬度根據數據大小而變化。如果數據有空間,則摺疊下來,否則表格寬度會增加。在primefaces數據表中設置寬度

在此先感謝。

回答

0

您需要爲您的數據表創建一個CSS定義。讓我們將它稱爲您p:datatable

<p:dataTable id="myDataTable" .... var="something"> 
    <p:column headerText="column1"> 
    #{something.propertyA} 
    </p:column> 

    <p:column headerText="column2"> 
    #{something.propertyB} 
    </p:column> 

</p:dataTable> 

然後你的CSS定義必須是:

#myDataTable.ui-datatable thead th, 
#myDataTable.ui-datatable tbody td, 
#myDataTable.ui-datatable tfoot td { 
    white-space: normal; 
    word-wrap: break-word; 
} 

鏈接解釋word-wrap: break-word

white-space: normal