解决:使用primefaces中datatable的scrollHeight时,列宽度设置失效有关问题
解决:使用primefaces中datatable的scrollHeight时,列宽度设置失效问题
解决:使用primefaces中datatable的scrollHeight时,列宽度设置失效问题
环境:primefaces-3.4.2
当使用下面代码设置了每列宽度,再使用scrollHeight时,每列的宽度设置不再有效.
<p:dataTable id="impAdjDatatable" rowKey="#{item.subNo}" selection="#{singleReportRerunVM.selectedRows}" widgetVar="impAdjDb" value="#{singleReportRerunVM.dataList}" var="item" scrollable="true" scrollHeight="350"> <p:column selectionMode="multiple" width="20"/> <p:column headerText="Sub#" width="60"> <h:outputText value="#{item.subNo}" /> </p:column> <p:column headerText="Contact Name" width="120"> <h:outputText value="#{item.cname}"/> </p:column> <p:column headerText="Email Address" width="140"> <h:outputText value="#{item.email}"/> </p:column> <p:column headerText="Account Name" width="120"> <h:outputText value="#{item.aname}"/> </p:column> <p:column headerText="Acct No" width="60"> <h:outputText value="#{item.acctNo}"/> </p:column> </p:dataTable>
此时,将设置每列宽度的代码由[width="60"]改为[style="width:60px"]即可.如下所示:
<p:dataTable id="impAdjDatatable" rowKey="#{item.subNo}" selection="#{singleReportRerunVM.selectedRows}" widgetVar="impAdjDb" value="#{singleReportRerunVM.dataList}" var="item" scrollable="true" scrollHeight="350"> <p:column selectionMode="multiple" style="width:20px"/> <p:column headerText="Sub#" style="width:60px"> <h:outputText value="#{item.subNo}" /> </p:column> <p:column headerText="Contact Name" style="width:120px"> <h:outputText value="#{item.cname}"/> </p:column> <p:column headerText="Email Address" style="width:140px"> <h:outputText value="#{item.email}"/> </p:column> <p:column headerText="Account Name" style="width:120px"> <h:outputText value="#{item.aname}"/> </p:column> <p:column headerText="Acct No" style="width:60px"> <h:outputText value="#{item.acctNo}"/> </p:column> </p:dataTable>