首页 > 解决方案 > TabView 内 DataTable 的 PrimeFaces DataExporter

问题描述

PF 8.0 JSF 2.2:我在 Tabview 中使用 DataTable,我在 DataExporter 中遇到问题,即使我使用 @parent..:@child(0) 作为目标,它也会将所有表一起导出。

        <p:tabView value="#{homeMB.users}" var="user" dynamic="true" id="tbview"
            cache="true" scrollable="true" style="background:transparent">
            <p:ajax event="tabChange" listener="#{homeMB.onTabChange}" />
            <p:tab>
                <f:facet name="title">
                    <span style="font-size:large">#{user.userId}</span>                 
                </f:facet>
                <p:dataTable var="c"
                    multiViewState="true" value="#{homeMB.model}" rows="10"
                    rowKey="#{c.id}" lazy="true" paginator="true"
                    paginatorPosition="bottom" styleClass="no-border"
                    paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown} {Exporters}"
                    currentPageReportTemplate="[{startRecord}-{endRecord} of {totalRecords}]"
                    rowsPerPageTemplate="10,20,30,40,50" rowIndexVar="inx">
                    <f:facet name="{Exporters}">
                        <div style="float: right; padding-top: 5px;">
                            <h:commandLink title="Export to Excel">
                                <p:graphicImage name="/images/excel.png" width="24" />
                                <p:dataExporter type="xls" target="@parent:@parent:@child(0)"
                                    fileName="Invoice(s)" />
                            </h:commandLink>
                        </div>
                    </f:facet>
............
            </p:tab>
        </p:tabView>


标签: primefacesjsf-2.2

解决方案


您是否尝试在要导出的表上设置 id,然后将目标设置为目标表的 id。例子:

<p:datatable id="first".../> 

<p:dataExporter type="xls" target="first" fileName="Invoice(s)" />

推荐阅读