0
votes

Primefaces Filter By a specific value

In Primefaces datatable, it can filter a specific column by the following code:

 <p:column style="text-align: center;"
        headerText="Name"
        sortBy="#{Name}"
        filterBy="#{Name}" id="NameColumn">
        <h:outputText id="Name"
                      value="#{formResultsRow.Name}" />
 </p:column>

The code above will generate a filter on the header of the column. and we can filter a particular value by entering the text in that filter.

Actual Result-

Header Field

Name

Mark
Mark 
Mark 
Mark 
David
David
David 

Desired Result-

What I'm looking for is a filter or a way that will produce a desired output without entering the value in the filter field. Or setting default value in primefaces datatable.

Desired output

Mark
Mark
Mark
Mark
1
You want to have a selectOneMenu in the filter area so that the user can select a value to filter for? - Selaron
@Selaron user is not going to enter any value, By default that particular value should filtered, - Glennjacob
It is like loading a Primefaces datatable with the default filtered value. - Glennjacob

1 Answers

0
votes
filterValue="Mark"

Or bind it to a string property on your bean with initial value of "Mark"

filterValue="#{myBean.nameFilter}"

But why do you want to filter data on the frontend like this?