如果我们使用< t:columns>如何对数据表进行排序在JSF中? [英] How to sort a data table if we are using <t:columns> in JSF?

查看:125
本文介绍了如果我们使用< t:columns>如何对数据表进行排序在JSF中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究战斧,我只想知道是否使用<t:columns>生成数据表,然后如何在单击该特定列的标题时对dataTable进行排序,就像我们在普通<t:commandSortHeader> >属性.请帮助.

I am studying tomahawk, I just want to know if I generate a datatable using <t:columns> then how to sort the dataTable on the click on the header of that particular column, like we are using <t:commandSortHeader> in normal <t:column> attribute. Kindly Help.

推荐答案

使用t:datatable确实不需要t:commandSortHeader,除非您要自定义用于排序的属性.

Using a t:datatable you don't really need the t:commandSortHeader, unless you want to customise what property it uses to sort.

这是您需要执行此操作的条件:

Here is what you need to get this working:

<h:form>
<t:dataTable
    id="data"
    value="#{BACKINGBEAN.DATA}"
    var="item"
    sortColumn="#{BACKINGBEAN.sortColumn}"
            sortAscending="#{BACKINGBEAN.sortAscending}">

...

<t:column defaultSorted="true" sortable="true">
    <f:facet name="header">
             <h:outputText value="header text"/>
    </f:facet>
    <h:outputText value="#{item.property}" />
</t:column>

...

</t:dataTable>
</h:form>

然后在您的支持bean中:

Then in your backing bean:

private String sortColumn;
private boolean sortAscending;

带有默认的getters/setters/lombok.它们只是为了让标签可以设置数据.

with default getters/setters/lombok. They are just so the tag can set data.

这是一个很好的参考: http://wiki.apache.org/myfaces/Working_with_auto_sortable_tables

This is a great reference: http://wiki.apache.org/myfaces/Working_with_auto_sortable_tables

但是它错过了关于后备bean属性的讨论,并且即使您没有任何表单元素也需要将其包装在<h:form>中.

But it misses the discussion about the backing bean properties, plus that it needs to be wrapped in a <h:form> even if you dont have any form elements.

这篇关于如果我们使用&lt; t:columns&gt;如何对数据表进行排序在JSF中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆