我得到了使用过滤器的primefaces数据表.一切正常.但是当我将数据表导出到excel文件时,标题不会显示.
在这里,我使用外部remoteCommand来处理服务器端的事件.
这是xhtml代码:
<h:form>
<p:commandButton value="#{dictionary['export_to_excel']}" icon="ui-icon-calculator" ajax="false">
<p:dataExporter type="xls" target=":gwsReportAllPartForm:gwsReportAllPartListDataTable" fileName="analytics"/>
</p:commandButton>
</h:form>
<h:form id="gwsReportAllPartForm">
<p:remoteCommand name="updateFilters" update=":gwsReportAllPartForm:gwsReportAllPartListDataTable"></p:remoteCommand>
<p:dataTable id="gwsReportAllPartListDataTable"
value="#{viewAllAnalyticsBean.gwsReportPartTwoList}"
var="report"
paginator="true"
rows="100"
paginatorTemplate="{PageLinks} {CurrentPageReport}"
currentPageReportTemplate="{currentPage} #{dictionary['out_of']} {totalPages}"
emptyMessage="#{dictionary['nothing_is_here']}"
scrollable="true"
scrollWidth="1050"
scrollHeight="500">
<p:ajax event="filter" listener="#{viewAllAnalyticsBean.onFilterDataTable}" oncomplete="updateFilters()"/>
<p:column headerText="#{dictionary['reporting_period']}" styleClass="columnCustomClass" style="width: 90px;position:relative; padding-bottom: 30px;">
<h:outputText value="#{report.gwsReportPartOne.year}, #{report.gwsReportPartOne.quarter}"/>
</p:column>
<p:column headerText="#{dictionary['subsoil_user_contract_register_number']}" styleClass="columnCustomClass" style="width: 90px;position:relative; padding-bottom: 30px;" filterBy="#{report.gwsReportPartOne.contractNumber}" filterMatchMode="contains" filterStyle="width:80px; position:absolute; bottom:4px;" filterValue="">
<h:outputText value="#{report.gwsReportPartOne.contractNumber}"/>
</p:column>
<p:column headerText="#{dictionary['gws_type']}" styleClass="columnCustomClass" style="width: 40px;position:relative; padding-bottom: 30px;" filterBy="#{report.gwsReportPartOne.gwsType.code}" filterMatchMode="contains" filterStyle="width:30px; position:absolute; bottom:4px;">
<h:outputText value="#{report.gwsReportPartOne.gwsType.code}" /> …Run Code Online (Sandbox Code Playgroud) 我正在使用带有过滤器选项的primefaces 5.0和datatable。但是键入一个字母并等待将被过滤和更新然后键入下一个字母是不方便的。这也会减慢服务器速度。因此,在填写过滤器选项然后进行过滤之后,需要按Enter键。
Primefaces 3.5中有filterDelay选项,但我在primefaces 5中看不到。
我曾经通过如下JavaScript代码来破解
$('th .ui-column-filter').each(function() {
var inp = $(this);
inp.unbind('keydown');
inp.unbind('keyup');
inp.unbind('keypress');
inp.keypress(function(event) {
if (event.keyCode == 13) {
alert("entered");
event.stopPropagation();
gwsReportAllPartListDataTable.filter();
return false;
}
});
});
Run Code Online (Sandbox Code Playgroud)
好吧,它没有用。
我如何用primefaces 5做到这一点?