Primefaces数据表不适用于过滤器+排序 [英] Primefaces datatable doesn't work with filter + sort
问题描述
我正在使用primefaces Datatable来显示大约1000行(和7列)。它的运行速度很快,但是当我过滤列并尝试按不同的列对数据集进行排序时,我会遇到奇怪的行为。
这是一个示例:在第一张图片中,加载时有数据表,看起来很棒。由于我正在处理敏感数据,因此受到了严格审查。在第二张图片中,我过滤了两列,数据表一直工作到现在为止,但是如果在那之后对第三列进行排序,则我将停止工作,不会显示正确的行。我的数据中不存在此处显示的值(nãodeterminado和很多白色字段)。
I'm using primefaces Datatable in order to show about 1000 rows (and 7 columns). 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.
这是我的代码:
<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>
我正在使用primefaces v6.0。 myBean是@SessionScoped。
I'm using primefaces v6.0. myBean is @SessionScoped.
为什么会发生此行为?
推荐答案
我注意到您在p:datatable标记中缺少一个重要值,该值是filterValue =,这是另一个类似于value =的列表,其中包含已过滤的值。
I noticed you are missing an important value in your p:datatable tag and that is filteredValue="" which is a another List similar to value="" which holds the filtered values.
filteredValue="#{myBean.filteredListaProtocolos}"
这篇关于Primefaces数据表不适用于过滤器+排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!