简体   繁体   English

Primefaces数据表不适用于过滤器+排序

[英]Primefaces datatable doesn't work with filter + sort

I'm using primefaces Datatable in order to show about 1000 rows (and 7 columns). 我正在使用primefaces Datatable来显示大约1000行(和7列)。 It's working fast, but I get weird behaviors when I filter a column and try sorting the dataset by a diferent column. 它的运行速度很快,但是当我过滤一列并尝试按不同的列对数据集进行排序时,我得到了奇怪的行为。 Here's an example: In the first picture there is the datatable when it's loaded, looking great. 这是一个示例:在第一张图片中,加载时有一个数据表,看起来很棒。 It's heavily censored because I'm working with sensitive data. 由于我正在使用敏感数据,因此受到了严格审查。 In the second picture I filter 2 columns, the datatable works fine until there, but if I sort a third column after that, I stops working, no correct row is shown. 在第二张图片中,我过滤了两列,数据表一直工作到现在为止,但是如果在那之后对第三列进行排序,则我将停止工作,不会显示正确的行。 The values shown there ("não determinado" and a lot of white fields) do not exist in my data. 我的数据中不存在此处显示的值(“nãodeterminado”和许多白色字段)。

我的数据表在加载时 and 过滤器+排序的任何组合后,它都会崩溃

Here's my code: 这是我的代码:

<p:dataTable var="prot" value="#{myBean.listaProtocolos}" rows="15" 
 sortBy="#{prot.dataEntradaArea}" sortFunction="#{myBean.sortXMLDatas}" 
 sortOrder="descending" paginator="true" style="font-size: 0.9em;" 
 paginatorPosition="bottom">
  <p:column filterBy="${prot.nrProtocolo}" filterMatchMode="contains" 
   width="8%" style="text-align:center">
    <f:facet name="header">ID</f:facet>
    <p:commandLink action="#{myBean.verDetalhesProtocolo}">
      <h:outputText value="#{prot.nrProtocolo}" 
       style="text-decoration: underline;"/>
      <f:setPropertyActionListener target="#{myBean.nrProtocolo}"
       value="#{prot.nrProtocolo}" />
    </p:commandLink>
  </p:column>
  <p:column filterBy="${prot.nrProcesso}" filterMatchMode="contains"
   width="10%">
    <f:facet name="header">Número</f:facet>
    <h:outputText value="#{prot.nrProcesso}" />
  </p:column>
  <p:column filterBy="${prot.tipoDeProtocoloDescricao}" 
   filterOptions="#{myBean.filtrosTipoDeProtocoloDescricao}" 
   width="10%">
    <f:facet name="header">Processo / Protocolo</f:facet>
    <h:outputText value="#{prot.tipoDeProtocoloDescricao}" />
  </p:column>
  <p:column filterBy="${prot.assunto}" sortBy="#{prot.assunto}"
   filterMatchMode="contains" width="30%">
    <f:facet name="header">Assunto</f:facet>
    <h:outputText value="#{prot.assunto}" />
  </p:column>
  <p:column filterBy="${prot.areaAtual}" sortBy="#{prot.areaAtual}"
   filterMatchMode="contains" width="15%">
    <f:facet name="header">Área Atual</f:facet>
    <h:outputText value="#{prot.areaAtual}" />
  </p:column>
  <p:column filterBy="${prot.tipo}" sortBy="#{prot.tipo}"
   filterMatchMode="contains" width="17%">
    <f:facet name="header">Tipo</f:facet>
    <h:outputText value="#{prot.tipo}" />
  </p:column>
  <p:column filterBy="${prot.dataEntradaAreaFormatada}" 
   sortBy="#{prot.dataEntradaArea}" sortFunction="#{myBean.sortXMLDatas}"
   filterMatchMode="contains" width="10%" style="text-align:center">
    <f:facet name="header">Data de Entrada</f:facet>
    <h:outputText value="#{prot.dataEntradaAreaFormatada}" />
  </p:column>
</p:dataTable>

I'm using primefaces v6.0. 我正在使用primefaces v6.0。 myBean is @SessionScoped. myBean是@SessionScoped。

Why is this behavior happening? 为什么会发生这种现象?

我注意到您在p:datatable标记中缺少一个重要值,该值是filteredValue =“”,这是另一个类似于value =“”的列表,其中包含已过滤的值。

filteredValue="#{myBean.filteredListaProtocolos}"

I had similar problem last year. 我去年有类似的问题。 I managed to make a workaround (i was not too happy with it) to use filterFunction=#{mbean.filter} and make my own filter function. 我设法做出了一种解决方法(我对此不太满意),使用filterFunction=#{mbean.filter}并创建了自己的过滤器功能。

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

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