【问题标题】:PF DataTable Filter Function Not WorkingPF 数据表过滤功能不起作用
【发布时间】:2017-06-02 13:42:35
【问题描述】:

Prime faces:6.0 我尝试在 PrimeFaces 数据表中启用全局搜索功能,类似于我在 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>

【问题讨论】:

    标签: jsf primefaces datatable


    【解决方案1】:

    您的 valuefilteredValue 不应指向同一个 bean-property。 filteredValue 应该针对具有相同签名的另一个(初始为空)列表。

    PF 会将匹配过滤器的结果移动到此列表中,并在每次调用 .filter() 时清除此列表 - 所以你现在只是丢弃你的“未过滤”结果,因为你指向相同的列表。

    【讨论】:

    • 我更新了我的原始帖子以包含您的建议。我正在读取的 bean 对象有 9 个字段。仍然没有用。我需要为 filterdValue 添加任何代码吗?现在我的 bean 中的过滤值是一个表示对象的 ArrayList。
    【解决方案2】:

    我的错。我没有对所有字段进行过滤。一旦我将过滤器添加到表的所有字段中,它就开始工作了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-24
      相关资源
      最近更新 更多