Primefaces dataTable applying filter on multiple field in a single column

自古美人都是妖i 提交于 2020-01-02 06:53:29

问题


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.

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

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>

Both the attributes firstName and lastName are Strings.

Any ideas if something like this is doable ?

Thank you!


回答1:


This should work

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


来源:https://stackoverflow.com/questions/17951749/primefaces-datatable-applying-filter-on-multiple-field-in-a-single-column

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!