Antoine Clement
Antoine Clement

Reputation: 43

Primefaces - How to filter a treetable using a selectCheckboxMenu?

I have a treetable with a filter based on a selectOneMenu, like the primefaces showcase Showcase.

I am trying to replace the selectOneMenu with a selectCheckBoxMenu to filter with multiple checked values.

I can the selectCheckBoxMenu with all the necessary items, I get the selected items in my Bean, yet I am not sure how to filter?

Do I have to rebuild my TreeNode on server side and remove all unwanted node?

Upvotes: 2

Views: 591

Answers (1)

Melloware
Melloware

Reputation: 12019

Yes I do this in my apps and you need to use filterMatchMode="in" for the custom filter.

<p:column id="colTemplateKey" headerText="#{appmsg['column.emailtemplate.templateKey']}"
            sortBy="#{row.emailTemplateKey.text}" filterBy="#{row.templateKey.text}" filterMatchMode="in"
            styleClass="col-left" width="180" sortPriority="1" sortOrder="asc">
            <f:facet name="filter">
                    <p:selectCheckboxMenu id="chkTemplateKeyFilter" label="#{appmsg['label.all']}" filter="true"
                                filterMatchMode="startsWith" updateLabel="true">
                                <p:ajax event="change" process="@this" oncomplete="PF('tableEntity').filter();" />
                                <p:ajax event="toggleSelect" process="@this" oncomplete="PF('tableEntity').filter();" />
                                <f:selectItems value="#{emailTemplateKeyFilterOptions}" />
                    </p:selectCheckboxMenu>
            </f:facet>
            <h:outputText value="#{row.emailTemplateKey.displayText}" />
</p:column>

Upvotes: 1

Related Questions