是否可以使用jsf h:datatable来拥有多行 [英] Is it possible to have multiple rows with jsf h:datatable

查看:318
本文介绍了是否可以使用jsf h:datatable来拥有多行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用h:datatable我们可以显示如下数据

With h:datatable we can display data as follows


  1. Jems

  2. tom

  3. chirs

  4. harry

  1. Jems
  2. tom
  3. chirs
  4. harry

但我可以展示如下所示:

but can I display the same as shown below:


  1. Jems 2. tom

  2. chris 4. harry

Ragards,
Abhi

Ragards, Abhi

推荐答案

您可以使用支持newspaperColumns的 t:dataTable组件 和报纸方向的属性。 newspaperColumns确定表格将被分割的列数和newspaperOrientation报纸表格中报纸列的方向。

You can use t:dataTable component that support "newspaperColumns" and "newspaperOrientation" attributes. newspaperColumns determine the number of columns the table will be divided over and newspaperOrientation the orientation of the newspaper columns in the newspaper table.

在您的示例中,bean:

In your example, the bean:

public class Bean {
    public List<String> getPeople() {
        List<String> people = new ArrayList<String>();
        people.add("Jems");
        people.add("tom");
        people.add("chirs");
        people.add("harry");
        return people;
    }
}

和JSF:

<t:dataTable var="person" value="#{bean.people}" rowIndexVar="index"
             newspaperOrientation="horizontal" newspaperColumns="2">
    <h:column>
        <h:outputText value="#{index + 1}"/>
    </h:column>
    <h:column>
        <h:outputText value="#{person}"/>
    </h:column>
</t:dataTable>

渲染为:

<table>
  <tbody id="_id13:tbody_element">
    <tr><td>1</td><td>Jems</td><td>2</td><td>tom</td></tr>
    <tr><td>3</td><td>chirs</td><td>4</td><td>harry</td></tr>
  </tbody>
</table>

这篇关于是否可以使用jsf h:datatable来拥有多行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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