简体   繁体   中英

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?

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM