In my application I am using global filter for searching the records in Primefaces DataTable and I have applied DataExporter on the same DataTable.
When I Search any record and go for export, it return me a complete list of data instead of filtered list.
My development environment is: java 6.0, Primefaces 3.2, JSF2.1, GlassFish Server 3.1.2, Netbeans 7.1.1
Enlisted below my dataTable and dataExporter code.
My dataTable code is::
<p:dataTable value="#{personnelController.allItems}"
emptyMessage="#{bundle.PersonnelEmpty}"
selectionMode="single"
dblClickSelect="false"
var="item"
id="tbl"
rowKey="#`enter code here`{item.id}"
sortBy="#{item.lastName}"
sortOrder="ascending"
widgetVar="itemTable"
paginator="true"
paginatorPosition="bottom"
paginatorAlwaysVisible="false"
currentPageReportTemplate="Page {currentPage} of {totalPages}"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
rows="10"
>
<f:facet name="header">
<p:outputPanel>
<h:outputText value="#{bundle.GlobalFilterPrompt}" />
<p:inputText id="globalFilter"
onkeyup="itemTable.filter()"
style="width:150px;"
/>
<p:watermark for="globalFilter" value="#{bundle.GlobalFilterWatermark}" />
</p:outputPanel>
</f:facet>
<p:ajax event="rowSelect" listener="#{personnelController.onRowSelectNavigate}" />
<p:column
sortBy="#{item.lastName}"
filterBy="#{item.lastName}"
filterStyle="display: none;"
>
<f:facet name="header">
<h:outputText value="#{bundle.PersonnelTitle_lastName}"/>
</f:facet>
<h:outputText value="#{item.lastName}"/>
</p:column>
<p:column
sortBy="#{item.firstName}"
filterBy="#{item.firstName}"
filterStyle="display: none;"
>
<f:facet name="header">
<h:outputText value="#{bundle.PersonnelTitle_firstName}"/>
</f:facet>
<h:outputText value="#{item.firstName}"/>
</p:column>
<p:column
sortBy="#{item.location.name}"
filterBy="#{item.location.name}"
filterStyle="display: none;"
>
<f:facet name="header">
<h:outputText value="#{bundle.PersonnelTitle_locations}"/>
</f:facet>
<h:outputText value="#{item.location.name}"/>
</p:column>
<p:column
sortBy="#{item.department.name}"
filterBy="#{item.department.name}"
filterStyle="display: none;"
>
<f:facet name="header">
<h:outputText value="#{bundle.PersonnelTitle_departments}"/>
</f:facet>
<h:outputText value="#{item.department.name}"/>
</p:column>
</p:dataTable>
I am exporting table data from outside the dataTable as::
<h:commandLink>
<p:graphicImage value="#{resource['images:excel.png']}" />
<p:dataExporter type="xls" target=":personnel:tbl" fileName="personnel" />
</h:commandLink>
Please suggest me if I am doing anything wrong.