2015-02-09 73 views
1

我们在项目中使用了primeface 5.1,JSF 2.2。 我在primefaces数据表中有一个问题,在过滤数据表后,排序将被破坏,如果尝试对表排序,数据表中不会显示任何记录。以下是jsf代码和问题快照。过滤表后,Primefaces数据表排序有奇怪的行为

<p:dataTable id="myTable" var="model" value="#{myBean.dynaModels}" widgetVar="tableWidget" editable="true" styleClass="ui-dyna-table" 
     rows="10" paginator="true" resizableColumns="true" tableStyle="width:auto" filterEvent="enter" emptyMessage="No service order found" 
     paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown} {CurrentPageReport}" draggableColumns="true" 
     currentPageReportTemplate="{startRecord} - {endRecord} of {totalRecords}" paginatorPosition="top" rowsPerPageTemplate="10,20,50,100" style="margin-right: 5px"> 
<f:facet name="header"> 
    <p:commandButton id="toggler" type="button" value="Columns" style="float:right" icon="ui-icon-calculator" /> 
    <p:columnToggler datasource="myTable" trigger="toggler" /> 
</f:facet> 
<c:forEach items="#{myBean.columnProperties}" var="columnProperty" > 
    <p:column headerText="#{columnProperty.descr}" rendered="#{columnProperty.componentType.value eq 'S1'}" filterBy="#{model.dyanModelMap[columnProperty.propertyKey].value}" 
       sortBy="#{model.dyanModelMap[columnProperty.propertyKey].value}" filterMatchMode="exact"> 
     <f:facet name="filter" > 
      <p:selectOneMenu style="width:111px" onchange="PF('tableWidget').filter()" > 
       <f:selectItem itemValue="" noSelectionOption="true"/> 
       <f:selectItems value="#{columnProperty.lov}" /> 
      </p:selectOneMenu> 
     </f:facet> 
     <h:outputText value="#{model.dyanModelMap[columnProperty.propertyKey].value}" /> 
    </p:column> 
    <p:column headerText="#{columnProperty.descr}" rendered="#{columnProperty.componentType.value eq 'TXT'}" filterBy="#{model.dyanModelMap[columnProperty.propertyKey].value}" 
       sortBy="#{model.dyanModelMap[columnProperty.propertyKey].value}" filterMatchMode="contains"> 
     <h:outputText value="#{model.dyanModelMap[columnProperty.propertyKey].value}" /> 
    </p:column> 
    <p:column headerText="#{columnProperty.descr}" rendered="#{columnProperty.componentType.value eq 'DT'}" filterBy="#{model.dyanModelMap[columnProperty.propertyKey].value}" sortBy="#{model.dyanModelMap[columnProperty.propertyKey].value}"> 
     <f:facet name="filter" > 
      <p:calendar showOn="button" onchange="PF('tableWidget').filter()" > 
      </p:calendar> 
     </f:facet> 
     <h:outputText value="#{model.dyanModelMap[columnProperty.propertyKey].value}" /> 
    </p:column> 
</c:forEach> 

Snapshot for the issue

回答

2

添加和实施DataTable中的filteredValue属性。这为我修好了。

+0

您是否正在使用普通5.1?不是精英版吗? Iirc,它是在精英版本中修复的。如果可能的话,请添加一些示例代码 – Kukeltje 2015-04-20 13:30:13

+0

为我工作。谢谢。即使在做了这些,并阅读了(非常有限的)关于它的文档之后,我也不明白为什么它会这样做。 – 2016-10-06 14:30:38