p:dataExporter selected rows only

天涯浪子 提交于 2019-12-18 09:11:42

问题


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


回答1:


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.




回答2:


Primefaces 5.2 not support generics(List<>), only Arrays ([]). It was fix on Primefaces 5.3.



来源:https://stackoverflow.com/questions/30054708/pdataexporter-selected-rows-only

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!