简体   繁体   English

如何让 PrimeFaces DataTable 进行排序?

[英]How do I get PrimeFaces DataTable to sort?

I just can't get sorting working.我只是无法进行排序工作。 I'm not sure if this should be posted in the Rain forums, because I am just using PrimeFaces for the first time, and purchased/installed the Rain layout.我不确定这是否应该发布在 Rain 论坛上,因为我只是第一次使用 PrimeFaces,并购买/安装了 Rain 布局。 So I'm not sure whether Rain is causing this or not.所以我不确定 Rain 是否导致了这种情况。

I define a standard p:dataTable and use:我定义了一个标准 p:dataTable 并使用:

<p:column headerText="Name" field="name" filterMatchMode="contains" />

And sort does not work.并且排序不起作用。

Here is my p:dataTable definition:这是我的 p:dataTable 定义:

<p:dataTable id="table" widgetVar="table" stripedRows="true" reflow="true"
  value="#{viewBean.dtos}"
  var="dto" selection="#{viewBean.dtos}" rowKey="#{dto.id}" paginator="true"
  rows="10" rowSelectMode="add">

My PrimeFaces version:我的 PrimeFaces 版本:

<!-- https://mvnrepository.com/artifact/org.primefaces/primefaces -->
<dependency>
    <groupId>org.primefaces</groupId>
    <artifactId>primefaces</artifactId>
    <version>10.0.0-RC2</version>
</dependency>

You are using a PrimeFaces version that has some bugs related to sort/filter data tables.您正在使用 PrimeFaces 版本,该版本有一些与排序/过滤数据表相关的错误。 Like this: DataTable / TreeTable : sortBy not working with client saving state method像这样: DataTable / TreeTable : sortBy不使用客户端保存 state 方法

You can apply the workarond, but you may face other issues, so it will be better if you switch to PrimeFaces 11, using the: PrimeFaces migration guide 10.0.0 -> 11.0.0您可以应用解决方法,但您可能会遇到其他问题,因此如果您切换到 PrimeFaces 11 会更好,使用: PrimeFaces 迁移指南 10.0.0 -> 11.0.0

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

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