2015-02-09 70 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