Primefaces DataTable在单个列中的多个字段上应用过滤器 [英] Primefaces dataTable applying filter on multiple field in a single column

查看:67
本文介绍了Primefaces DataTable在单个列中的多个字段上应用过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 p:datatable 列出了用户。该列中的一个包含用户的名+姓的串联,我希望能够在同一过滤器字段中对这两个值进行过滤,以便它尝试匹配名称和名称上的过滤器

I have a p:datatable which lists users. One of the column contains the concatenated First Name + Last Name of the user and I'd like to be able to filter on both these values in the same 'filter field' so that it tries to match the filter on the name as well as on the first name.

ie:用户:鲍勃·格林和史蒂夫·罗斯,如果我输入过滤器 o,则两个用户都将出现在过滤器中

i.e.: users: "Bob Green" and "Steve Ross", if I enter the filter 'o', both users will appear in the filtered list.

dataTable:

The dataTable:

<p:dataTable id="users" 
                   value="#{userCtrl.userList}" 
                   filteredValue="#{userCtrl.filteredUserList}"
                   var="user"
                   sortMode="multiple">

         <!-- FIRST NAME + LAST NAME -->
         <p:column id="col_name" 
                   filterBy="#{user.name} ADD SOMETHING HERE FOR FIRST NAME?" 
                   headerText="Name"
                   filterMatchMode="contains">
            <h:outputText value="#{user.firstName} #{user.lastName}" />
         </p:column>



</p:dataTable>

firstName和lastName属性都是字符串。

Both the attributes firstName and lastName are Strings.

有什么想法可行吗?

谢谢!

推荐答案

这应该有效

filterBy="#{user.firstName} #{user.lastName}"

这篇关于Primefaces DataTable在单个列中的多个字段上应用过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆