正如您在 excel 表中制作的上表所见,我想使用 Primefaces 数据表创建一个表。表格行必须基于两组列(前 2 列和前 7 列)进行分组,由红色和黄色框表示,我还需要添加汇总行,它将计算“Invia Totale”中的值的总和蓝色框表示的内部组和外部组的列。我已经根据表数据的逻辑对数据库记录进行了分组。
我的 xhtml 文件:
<p:dataTable id="tbltotaliFatture" widgetVar="tbltotaliFatture"
value="#{bbean.outGroupList}" var="outerGroup"
emptyMessage="#{global['msgNessunRisultatoTrovato']}"
scrollRows="10" scrollable="true" scrollHeight="400"
scrollWidth="100%">
<p:columnGroup type="header">
<p:row>
<p:column style="width:250px"
headerText="#{quadraturaFattureEura['label_centrale']}" />
<p:column style="width:130px"
headerText="#{quadraturaFattureEura['label_file']}" />
<p:column style="width:110px"
headerText="#{quadraturaFattureEura['label_compagnia']}" />
<p:column style="width:110px"
headerText="#{quadraturaFattureEura['label_anno_rif']}" />
<p:column style="width:110px"
headerText="#{quadraturaFattureEura['label_mese_rif']}" />
<p:column style="width:110px"
headerText="#{quadraturaFattureEura['lbl_anno_competenza']}" />
<p:column style="width:110px"
headerText="#{quadraturaFattureEura['lbl_tipo_costo']}" />
<p:column style="width:130px"
headerText="#{quadraturaFattureEura['lbl_modalita_pagamento']}" />
<p:column style="width:150px"
headerText="#{quadraturaFattureEura['lbl_totale_inviato']}" />
<p:column style="width:150px"
headerText="#{quadraturaFattureEura['lbl_totale_in_errore']}" />
</p:row>
</p:columnGroup>
<p:subTable var="innerGroup" value="#{outerGroup.innerGroupList}">
<p:subTable var="row" value="#{innerGroup.mappedServiceMBeanList}">
<p:column>
<h:outputText id="dscCentrale"
styleClass="value-text text-right"
value="#{row.codCentrale}">
</h:outputText>
</p:column>
<p:column>
<h:outputText id="dscFile"
styleClass="value-text text-right"
value="#{row.codFile}">
</h:outputText>
</p:column>
<p:column>
<h:outputText id="codMulticompagnia"
styleClass="value-text text-right"
value="#{row.codMultiCompag}">
</h:outputText>
</p:column>
<p:column>
<h:outputText id="annoRiferimento"
styleClass="value-text text-right"
value="#{row.annoRiferi}">
</h:outputText>
</p:column>
<p:column>
<h:outputText id="meseRiferimento"
styleClass="value-text text-right"
value="#{row.meseRiferi}">
</h:outputText>
</p:column>
<p:column>
<h:outputText id="annoCompetenza"
styleClass="value-text text-right"
value="#{row.annoCompetenza}">
</h:outputText>
</p:column>
<p:column>
<h:outputText id="tipoCosto"
styleClass="value-text text-right"
value="#{row.tipoCosto}">
</h:outputText>
</p:column>
<p:column>
<h:outputText id="modalitaPagamento"
styleClass="value-text text-right"
value="#{row.modalitaPagamento}">
</h:outputText>
</p:column>
<p:column>
<h:outputText id="totaleInviato"
styleClass="value-text text-right"
value="#{row.totaleInviato}">
</h:outputText>
</p:column>
<p:column>
<h:outputText id="totaleInErrore"
styleClass="value-text text-right"
value="#{row.totaleInErrore}">
</h:outputText>
</p:column>
<p:columnGroup>
<p:column style="background-color: #F0F0F0;" colspan="8" />
<p:column>
<h:outputText id="innerTotal"
styleClass="value-text text-right"
value="#{innerGroup.innerTotal}">
</h:outputText>
</p:column>
<p:column style="background-color: #F0F0F0;" />
</p:columnGroup>
<p:columnGroup>
<p:row>
<p:column style="background-color: #F0F0F0;" colspan="9" />
<p:column style="background-color: #F0F0F0;">
<h:outputText styleClass="value-text text-bold text-right"
value="#{outerGroup.outerTotal}">
</h:outputText>
</p:column>
</p:row>
</p:columnGroup>
</p:subTable>
</p:subTable></p:dataTable>
Java Bean 类:- QuadraturaFattureEuraOuterGroup.java
public class QuadraturaFattureEuraOuterGroup {
private static final long serialVersionUID = 947989833069960727L;
private String outerTotal;
private List<QuadraturaFattureEuraInnerGroup> innerGroupList;
}
QuadraturaFattureEuraInnerGroup.java
public class QuadraturaFattureEuraInnerGroup implements Serializable{
private static final long serialVersionUID = 7411230855825585398L;
private String innerTotal;
private List<QuadraturaFattureEuraMBean> mappedServiceMBeanList;
}
QuadraturaFattureEuraMBean.java
public class QuadraturaFattureEuraMBean {
// list of properties being fetched from data-base and to be rendered as UI table rows
}
我的表数据没有呈现,我也没有收到任何错误。请帮我解决这个问题,因为我没有找到像我这样的场景的任何解决方案。