【问题标题】:is there any way to sort a datatable alphabetically in primefaces有没有办法在primefaces中按字母顺序对数据表进行排序
【发布时间】:2017-10-11 00:20:31
【问题描述】:

我想知道是否有任何方法可以使用自定义分页模板或其他方式按字母顺序对 primefaces 中的数据表进行排序

<p:dataTable var="car" value="#{dtPaginatorView.cars}" rows="10"
                         paginator="true"
                         paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                         rowsPerPageTemplate="5,10,15">


    </p:dataTable>

【问题讨论】:

  • 为什么要使用自定义分页器模板? primefaces 数据表的正常排序功能已经支持字母排序:primefaces.org/showcase/ui/data/datatable/sort.xhtml 如果您想在数据表显示之前对其进行排序,只需对汽车列表进行排序即可。
  • 数据表还有一个 sortOrder 属性,用于在 xhtml 中设置表的初始排序。
  • 我想将分页器设置为仅显示以字母开头的元素,例如单击“A”按钮显示:“Audi”、“Alfa Romeo”.. Bentley 的“B” 、别克等……

标签: jsf primefaces datatable


【解决方案1】:

在这里你可以找到Primefaces Datatable SortBy Attribut

    <p:column headerText="Color" sortBy="#{car.color}">
        <p:inputText value="#{car.color}" />
    </p:column>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多