过滤表后,Primefaces数据表排序有奇怪的行为

时间:2015-02-09 05:10:28

标签: jsf primefaces glassfish jsf-2.2

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

<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

1 个答案:

答案 0 :(得分:2)

在datatable中添加并实现filteredValue属性。这为我解决了。