Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

jsf - p:dataExporter selected rows only

I have a <p:dataTable> with the multiple selection checkbox. I want to export only some rows to my pdf. Right now when I try to export based on the selected rows it gives me only the rows from the top. For example if I have 10 rows in my datatable and I select 1,4,7,9 to be exported to my PDF. I always get rows 1,2,3,4 in my pdf. I am using the PrimeFaces 5.1 jar. I tried it with 5.2 jar also, Still same issue.

<p:dataTable id="dataall"
             var="cars"
             value="#{carsEntry.carssUser}"
             rows="10"
             rowIndexVar="rowId"
             paginator="true"
             rowKey="#{cars}"
             paginatorTemplate="{CurrentPageReport}
             {FirstPageLink} {PreviousPageLink}
             {PageLinks} {NextPageLink}
             {LastPageLink} {RowsPerPageDropdown}"
             rowsPerPageTemplate="5,10,15"
             editable="true"
             selection="#{carsEntry.selectedRows}">

    <p:column selectionMode="multiple" exportable="false"/>

    <p:column headerText="ID" sortBy="#{cars.id}">
        <h:outputText value="#{cars.id}" />
    </p:column>
</p:dataTable>

<h:commandLink>
    <h:outputText  value="PDF" />

    <p:dataExporter type="pdf"
                    target="dataall"
                    fileName="AllCars"
                    selectionOnly="true"/>
</h:commandLink>

Checked these two but still no clear answer.

http://forum.primefaces.org/viewtopic.php?f=3&t=31804 https://code.google.com/p/primefaces/issues/detail?id=7406

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Thanks to my friend Sathish. I was able to find out a work around for this issue. I populate the selected values to a new datatable and export that data. Hence I get the correct values exported. I make rendered="false" for the second data table.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...