I have a table on which I can select several rows through checkbox
what would be the column selector
:
<p:dataTable value="#{cityBean.cities}" var="city" id="dt_cities" widgetVar="w_cities"
filteredValue="#{cityBean.filteredCities}"
selection="#{cityBean.selectedCities}"
rowKey="#{city.id}"
rowSelectMode="add"
scrollable="true" scrollHeight="300">
<p:column id="selector" selectionMode="multiple" style="text-align:center" />
<p:column headerText="Name" sortBy="#{city.name}" filterBy="#{city.name}" filterMatchMode="contains">
<h:outputText value="#{city.name}" />
</p:column>
</p:dataTable>
Then I have two buttons with which I can export the selected rows (using the selectionOnly="true"
) in two ways: XLS
or PDF
.
<h:commandLink >
<p:graphicImage url="#{resource['icons/excel_exports.png']}" />
<p:dataExporter type="xls" target="dt_cities" fileName="list_cities" selectionOnly="true" />
</h:commandLink>
<h:commandLink>
<p:graphicImage url="#{resource['icons/pdf_exports.png']}" />
<p:dataExporter type="pdf" preProcessor="#{cityBean.pdfLandscape}"
target="dt_cities" fileName="list_cities"
selectionOnly="true"/>
</h:commandLink>
The bug
one I find is that for example: I have a 10 elementos
numbered list of 1 al 10
, I select the elements 9, 8, 5 y 2
. When clicking on the export buttons they appear to me 4 elementos
but they do not correspond to your selection, the elements appear 1, 2, 3 y 4
.
It recognizes how many elements are selected but does not know how to interpret which ones they are.
I am currently using: JSF 2.2
and Primefaces 5.1 RC1
.