[英]setting Column width for Datatable primefaces
在設置數據表的列寬時需要一些幫助。 但是,數據表寬度似乎不一致。數據表中列的寬度似乎取決於列標題長度。 請參考下面的代碼。
<p:column style="text-align: left; width:15px;" >
<f:facet name="header">
<h:outputText id="SalesHistoryID" value="View Sales History/Forecast"/>
</f:facet>
<h:commandLink id="ForecastID" value="View"/>
在上述情況下,列標題值長度“查看銷售歷史/預測”似乎很大,因此列寬似乎也會根據列標題文本值進行擴展。 如果有任何方法可以實際保持列寬的均勻性並且不依賴於列標題文本值,請告訴我。
如果列標題文本長度太大,有沒有辦法保持列寬的均勻性? 請協助。 提前致謝
要設置數據表的列寬,請為datatable設置resizableColumns =“true”屬性,然后使用width =“10”為列設置特定列的寬度 ,這就是:)
<p:dataTable id="dataTable" var="question" value="#{QuestionsMB.questionsList}" rowKey="#{question.id}"
paginator="true" rows="10" selection="#{QuestionsMB.selectedQuestions}"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
lazy="true" rowsPerPageTemplate="10,15,50,100"
resizableColumns="true"
emptyMessage="No question found with given criteria" >
<f:facet name="header">
Questions List
</f:facet>
<p:column selectionMode="multiple"/>
<p:column id="questionHeader" width="10">
<f:facet name="header">
<h:outputText maxlength="20" value="Question text :" />
</f:facet>
<p:commandLink value="#{question.questionText}" update=":questionDetailForm:display" oncomplete="questionDialog.show()" title="View">
<f:setPropertyActionListener value="#{question}" target="#{QuestionsMB.selectedQuestion}" />
</p:commandLink>
</p:column>
</p:dataTable>
<p:dataTable id="id" value="#{bean.mainList}" var="dp" tableStyle="width:auto" resizableColumns="true" >
tableStyle="width:auto" , resizableColumns="true"
這將有助於擬合列
table元素上的style =“table-layout:fixed”就是你要找的東西。 默認表格布局為“auto”,這可確保沒有單元格小於內容。 無法適應的文本會溢出。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.