简体   繁体   English

使用FilterBy的PrimeFaces 3.5.14 DataTable

[英]PrimeFaces 3.5.14 DataTable using FilterBy

I'm using PrimeFaces 3.5, with a datatable that i need use a FilterBy component. 我正在使用PrimeFaces 3.5,并且需要使用FilterBy组件的数据表。 In show case, it works ok: http://www.primefaces.org/showcase/ui/datatableFiltering.jsf 在演示情况下,它可以正常工作: http : //www.primefaces.org/showcase/ui/datatableFiltering.jsf

well, when i do my first filter, its work and it show me result, but when i do a second filter, it stop working. 好吧,当我执行第一个过滤器时,它的工作会显示结果,但是当我进行第二个过滤器时,它将停止工作。

See my xHTML: 查看我的xHTML:

                                                                                       <p:dataTable id="users" 
                                              var="user" 
                                              value="#{userMB.users}" 
                                              rowKey="#{user.id}"
                                              selection="#{userMB.userSelected}" 
                                              selectionMode="single"
                                              rows="10"
                                              paginator="true"
                                              filteredValue="#{userMB.filteredUser}"
                                              paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"

                                    >

                                    <p:column headerText="Id" >
                                        #{user.id}
                                    </p:column>

                                     <p:column headerText="Login" filterBy="#{user.login}">
                                        #{user.login}
                                    </p:column>

                                </p:dataTable>     

Observations: userMB its my managed bean, @SessionScoped users it's a List filteredUser it's a List 观察结果:userMB是我的托管bean,@ SessionScoped用户是列表ListfilterUser是列表

it's all... thank a attention :) 全部...感谢关注:)

I am new here too, but this example worked for me. 我也是新来的,但是这个例子对我有用。 I see some problems in your example. 我在您的示例中看到了一些问题。

First if you put var="user" then rowKey="#{userMB.id}" must be rowKey="#{user.id}" Same here: 首先,如果您输入var =“ user”,则rowKey =“#{userMB.id}”必须为rowKey =“#{user.id}”在这里相同:

As you see I removed filterValue="#{usuario.login}" as I don't used this. 如您所见,我删除了filterValue =“#{usuario.login}”,因为我没有使用它。

In the end this should look like this: 最后,应如下所示:

  <p:dataTable id="users" 
  var="user" 
  value="#{userMB.users}" 
  rowKey="#{user.id}"
  selection="#{userMB.userSelected}" 
  selectionMode="single"
  rows="10"
  paginator="true"
  filteredValue="#{userMB.filteredUser}"
  paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"

  >

      <p:column headerText="Id" >
      #{user.id}
      </p:column>

      <p:column headerText="Login" sortBy="#{user.login}" filterBy="#{user.login}">
      #{user.login}
      </p:column>

  </p:dataTable>

Maybe its not problem, but I used @ViewScoped. 也许不是问题,但我使用了@ViewScoped。

Hint: you can be interested in filterMatchMode="contains" 提示:您可能对filterMatchMode =“ contains”感兴趣

I hope I helped you. 希望对您有帮助。

this is a working PF3.5 datatable dont forget to wrap it inside an 这是一个有效的PF3.5数据表,不要忘记将其包装在

<p:dataTable id="surveyTable" var="survey" value="#{surveyBean.surveys}" widgetVar="surveysTable" 
                                     emptyMessage="Keine Umfragen zu diesem Suchbegriff vorhanden" filteredValue="#{surveyBean.filteredSurveys}" 
                                     paginator="true" rows="10"  
                                     paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                                     rowsPerPageTemplate="5,10,15">
                            <f:facet name="header">  
                                Liste der Umfragen 
                                <p:outputPanel>  
                                    <h:outputText value="Suchen:" />  
                                    <p:inputText id="globalFilter" onkeyup="surveysTable.filter()" style="margin-left:5px;width:150px" />  
                                </p:outputPanel>
                            </f:facet> 
                            <p:column id="idColumn" headerText="ID" filterBy="{survey.id}" filterMatchMode="contains">  
                                <h:outputText value="#{survey.id}" />  
                            </p:column>
                            <p:column id="titleColumn" filterBy="#{survey.title}" headerText="Bezeichnung" filterMatchMode="contains">  
                                <h:outputText value="#{survey.title}" />  
                            </p:column>
                            <p:column id="activeColumn" headerText="Aktiv" filterBy="#{survey.active}" filterOptions="#{surveyBean.surveyOptions}"  
                                      filterMatchMode="exact">   
                                <h:outputText value="#{survey.active}" />  
                            </p:column>
                            <p:column id="toggleColumn">  
                                <p:rowToggler />  
                            </p:column> 
                            <p:rowExpansion>  
                                <h:panelGrid id="display" columns="2" cellpadding="4" style="width:300px;"  
                                                styleClass=" ui-widget-content grid">  

                                    <f:facet name="header">  
                                        Details der Umfrage 
                                    </f:facet>  

                                    <h:outputText value="Bezeichnung:" />  
                                    <h:outputText id="model" value="#{survey.title}" />  

                                    <h:outputText value="Status:" />  
                                    <h:outputText id="year" value="#{survey.active}" />  

                                    <h:outputText value="ID:" />  
                                    <h:outputText value="#{survey.id}"/>   
                                </h:panelGrid>  

                            </p:rowExpansion> 
                        </p:dataTable>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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