filtering using dropdown list primefaces datatable

11,615

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>
Share:
11,615
yahh
Author by

yahh

Updated on June 17, 2022

Comments

  • yahh
    yahh almost 2 years

    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>