在我的應用程序中,我使用全局過濾器搜索Primefaces DataTable中的記錄,並且我在同一DataTable上應用了DataExporter。DataExporter不適用於Primefaces 3.2中的已過濾數據表0123:
當我搜索任何記錄並導出時,它會返回一個完整的數據列表,而不是過濾列表。
我的開發環境是: 的Java 6.0,Primefaces 3.2,JSF2.1,GlassFish應用服務器3.1.2,7.1.1 Netbeans的
入伍低於我的DataTable,並dataExporter代碼。
我dataTable的代碼::
<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>
我從數據表外導出表數據爲::
<h:commandLink>
<p:graphicImage value="#{resource['images:excel.png']}" />
<p:dataExporter type="xls" target=":personnel:tbl" fileName="personnel" />
</h:commandLink>
請建議我,如果我做錯什麼。
我使用dataexporter用過濾的數據表,並出口僅過濾後的數據。你能發佈你的代碼嗎? – fareed 2012-07-11 05:43:03
看到我更新的答案,我希望這可以解決您的問題 – fareed 2012-07-14 04:38:29