如何使用PrimeFaces数据表实现嵌套子表?

时间:2018-08-30 11:23:17

标签: jsf primefaces jsf-2

enter image description here

从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

}

我的表数据未呈现,也没有任何错误。 请帮我解决这个问题,因为在类似我的场景中找不到任何解决方案。

0 个答案:

没有答案