Prime faces : 6.0我尝试在PrimeFaces DataTable中启用全局搜索功能,类似于我在PrimeFaces展示中看到的功能。我输入的任何搜索字符串都返回一个空的结果集。我能够实现分页,但全局搜索是一个问题。下面是我的代码:
<h:form>
    <p:dataTable var="pres" value="#{presBean.presentations}" rows ="10"
    paginator="true" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
    rowsPerPageTemplate="10,25,100" widgetVar="presTable" **filteredValue="#{presBean.filteredPres}"**>
    <p:column headerText="Title" sortBy="#{pres.title}">
    <!--f:facet name="header" sortBy="#{pres.title}">
        <h:outputText value="Title" />
    </f:facet-->
    <h:outputText value="#{pres.title}" />
</p:column>
<p:column headerText="Presenter" sortBy="#{pres.presenter}">
    <!--f:facet name="header">
        <h:outputText value="Presenter" />
    </f:facet-->
    <h:outputText value="#{pres.presenter}" />
</p:column>
</h:form>发布于 2017-06-03 01:56:47
您的value和filteredValue不应该指向相同的bean属性。filteredValue应该以具有相同签名的另一个(初始为空)列表为目标。
PF会将匹配过滤器的结果移动到这个列表中,并且还会在每次调用.filter()时清除这个列表-所以此时您只是丢弃了“未过滤”的结果,因为您指向的是同一个列表。
发布于 2017-06-12 23:24:00
是我的错。我没有对所有字段进行过滤。一旦我将过滤器添加到表的所有字段,它就开始工作了。
https://stackoverflow.com/questions/44330404
复制相似问题