使用PrimeFaces菜单栏过滤

时间:2017-06-07 08:53:16

标签: primefaces

当在页面home.xhtml中使用这样的导航栏时,是否有可能从JSF rich dataTable(我使用复合属性)中过滤数据:

     <p:menubar>
                <p:submenu label="Categories">
                    <p:submenu label="ANTIQUES">
                        <p:menuitem value="European Antiques"></p:menuitem>
                        <p:menuitem value="Asian Antiques"></p:menuitem>
                    </p:submenu>
               </p:submenu>
    </p:menubar>

我想根据所选项目更新表格的值(所选项目是表格中的类别)。问题是该表位于另一页(listAuctions.xhtml):

<h:form id="form">
        <rich:dataTable id="auctionsTable" rows="7" value="#{cc.attrs.auctions}" var="auct" border="1" styleClass="flat list auctions" rendered="#{cc.attrs.rendered and not empty cc.attrs.auctions}" filterVar="filterValue" rowClasses="odd-row, even-row">


            <rich:column sortBy="#{auct.name}" sortOrder="ascending" >
                <h:commandLink value="#{auct.name}" action="#{auctionManager.goToDetailsEnglish()}" rendered="#{auct.auctionTypes eq 'ENGLISH'}">
                    <f:param  name="auctionId" value="#{auct.id}"/>
                </h:commandLink>
                <h:commandLink value="#{auct.name}" action="#{auctionManager.goToDetailsDutch()}" rendered="#{auct.auctionTypes eq 'DUTCH'}">
                    <f:param  name="auctionId" value="#{auct.id}"/>
                </h:commandLink>
            </rich:column>
            <rich:column sortBy="#{auct.category}"
                     filterExpression="#{empty filterValue or fn:startsWith(auct.category, filterValue)}"
                     filterValue="#{filterBean.category}">
                    <f:facet name="header">CATEGORY</f:facet>
                    <h:outputText value="#{auct.category}"/>
                 </rich:column>

...

Those 2 pages are connected in whe welcome file like this:

<ui:composition template="templates/home.xhtml">
<ui:param name="activeTab" value="list" />

<ui:define name="content">
    <h2>Auction List</h2>
    <a:listAuctions auctions="#{auctionManager.all}"/>
</ui:define>

谢谢!

1 个答案:

答案 0 :(得分:1)

试试这个:<p:menuItem onclick="PF('dataTableWidgetVarName').filter()" />

将widgetVar添加到数据表:<p:dataTable widgetVar="dataTableWidgetVarName" ... />