我有一个自定义 dataTable 标记,我在所有视图中都使用它,它位于:src/main/webapp/WEB-INF/tags/custom_datatable.xhtml
我的问题是,如果我在一个或多个可过滤列上进行过滤并使用 dataExporter 进行导出,则列过滤会丢失,因此导出会忽略这些额外的过滤。我怎样才能改变这个?
这是自定义数据表标签的来源:
<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:p="http://primefaces.org/ui">
<script type="text/javascript">
$ = jQuery;
var scrollPos;
function saveScrollPos() {
scrollPos = $(".ui-datatable-scrollable-body").scrollTop();
}
function getScrollPos() {
$(".ui-datatable-scrollable-body").scrollTop(scrollPos);
}
</script>
<p:dataTable id="#{id}" value="#{value}" var="item" widgetVar="#{widgetVar}"
draggableColumns="true" filterDelay="1000"
styleClass="breakwords"
emptyMessage="#{bundle.EmptyMessage}" filteredValue="#{controller.filteredItems}"
selectionMode="single" selection="#{controller.selected}"
rowKey="#{item.id}"
rowStyleClass="#{rowStyleClass}"
sortBy="#{sortBy}" sortOrder="#{(sortOrder!=null)?sortOrder:'ascending'}"
scrollRows="30" scrollable="true" liveScroll="true" scrollHeight="400"
tableStyle="#{tableStyle}"
>
<p:ajax event="rowSelect" update="createButton viewButton editButton deleteButton"/>
<p:ajax event="rowUnselect" update="createButton viewButton editButton deleteButton"/>
<f:facet name="header">
<p:outputPanel >
<p:inputText id="globalFilter" style="width:150px" onkeyup="PF('#{widgetVar}').filter()" placeholder="Searching..."/>
<h:commandLink style="float:right">
<p:graphicImage name="/images/csv.png" width="24"/>
<p:dataExporter type="csv" target="#{id}" fileName="list"/>
</h:commandLink>
<h:commandLink style="float:right">
<p:graphicImage name="/images/excel.png" width="24"/>
<p:dataExporter type="xls" target="#{id}" fileName="list" />
</h:commandLink>
<p:commandButton icon="ui-icon-refresh" oncomplete="javascript:window.location.reload();" action="#{controller.refresh}" value="Refresh" style="float:left" />
<p:commandButton id="toggler" type="button" value="Oszlopok" style="float:left" icon="ui-icon-calculator" />
<p:columnToggler datasource="#{id}" trigger="toggler" >
<p:ajax event="toggle" listener="#{controller.getControllerDelegate().onToggle}" />
</p:columnToggler>
</p:outputPanel>
</f:facet>
<ui:insert />
</p:dataTable>
</ui:composition>
我的 Primefaces 版本:
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>6.2</version>
<type>jar</type>
</dependency>