Filtering using dropdown list primefaces datatable

datatablejsfprimefaces

jsf 2.0 primefaces 5.1 glassfish 4

i am using filtering via a dropdown list, when i click an item on the list the datatable gets filtered but the value in the dropdown list still shows "select one" instead of the selected value

<p:column headerText="Region" filterBy="#{wan.Region}"
            filterMatchMode="contains" >
      <f:facet name="filter">
          <p:selectOneMenu onchange="PF('table').filter()">
                <f:selectItem itemLabel="Select One" itemValue="#{null}"
                              noSelectionOption="true" />
                <f:selectItems value="#{wandbBean.regions}" />
          </p:selectOneMenu>
      </f:facet>
      <h:outputText value="#{wan.Region}" />
</p:column>

Best Solution

The problem occurs because you did not set value="#{wan.Region}" into <p:selectOneMenu onchange="PF('table').filter()">.

Therefore, the exactly code should be

<p:column headerText="Region" filterBy="#{wan.Region}"
            filterMatchMode="contains" >
      <f:facet name="filter">
          <p:selectOneMenu value="#{wan.Region}" onchange="PF('table').filter()">
                <f:selectItem itemLabel="Select One" itemValue="#{null}"
                              noSelectionOption="true" />
                <f:selectItems value="#{wandbBean.regions}" />
          </p:selectOneMenu>
      </f:facet>
      <h:outputText value="#{wan.Region}" />
</p:column>
Related Question