简体   繁体   English

对一个 Primefaces 表进行排序,该表填充了来自集合的数据

[英]Sort a Primefaces Table that is filled with data from a collection

I'm having trouble getting the sorting to work in my PrimeFaces data table.我无法在我的 PrimeFaces 数据表中进行排序。

This is my.xhtml file:这是我的.xhtml 文件:

<p:dataTable id="audiobooksTable" var="audiobook" value="#{audiobookListController.audiobooks}">
    <f:facet name="header">
        Audiobooks
    </f:facet>
    
    <p:column headerText="Audiobookname" sortBy="#{audiobook.title}" >
        <h:outputText value="#{audiobook.title}" />
    </p:column>

The arrows for sorting show up but clicking them has no effect.用于排序的箭头会显示,但单击它们没有效果。

audiobook.title has the datatype String . audiobook.title的数据类型为String There are also other columns that I want to sort by (with data types int and double ) but those also don't work.我还想按其他列进行排序(数据类型为intdouble ),但这些列也不起作用。

The AudiobookListController returns Collection<AudioBook> . AudiobookListController返回Collection<AudioBook>

Any help would be greatly appreciated.任何帮助将不胜感激。

If you are using Primefaces 10 , try downgrading to Primefaces 8 , there is an issue with sortBy.如果您使用的是Primefaces 10 ,请尝试降级到Primefaces 8 , sortBy 存在问题

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

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