具有行跨度的 Primefaces 数据表 [英] Primefaces dataTable with rowspan
问题描述
我对 JSF primefaces 3.1 很陌生.我尝试构建一个复杂"的表,但找不到使用 dataTable 的好的解决方案(我需要一个排序组件).
I'm quite new with JSF primefaces 3.1. I try to build a "complex" table and I cannot find a good solution using dataTable (I need a sorting component).
我想使用像这样的基本 POJO 构建一个与以下 HTML 表示等效的表格:
I would like to build a table equivalent to the following HTML representation, using a basic POJO like that:
String field1
String field2
List<String> fields3 // 3 items
String field4
<table border="1">
<tr>
<td rowspan="3">col1</td>
<td rowspan="3">col2</td>
<td>col3.1</td>
<td rowspan="3">col4</td>
</tr>
<tr>
<td>col3.2</td>
</tr>
<tr>
<td>col3.3</td>
</tr>
</table>
我提供的信息可能太少,所以如果您需要,请告诉我:)我希望我的问题很清楚.
I give maybe too little information, so if you need it, please tell me :) I hope that my question is clear.
谢谢
推荐答案
一个坚如磐石且灵活的自定义网格解决方案是将
A rock-solid and all flexible solution for custom grids is to use <c:forEach> together with Primefaces <p:panelGrid>:
<html ... xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:p="http://primefaces.org/ui">
<p:panelGrid>
<p:row>
<p:column styleClass="ui-state-default" colspan="2"><!-- header -->
<h:outputText value="Some Header"/>
</p:column>
...
</p:row>
<p:row><!-- other header row -->
...
</p:row>
<c:forEach items="#{list}" var="element">
<p:row>
<p:column styleClass="ui-state-default" rowspan="#{list.sublist.someSizeExpression}"><!-- left rowspan -->
<h:outputText value="#{element.name}"/>
</p:column>
<c:forEach items="#{element.sublist}" var="subelement">
<p:column>
<h:selectBooleanCheckbox/>
</p:column>
</c:forEach>
</p:row>
</c:forEach>
</p:panelGrid>
</html>
看起来不错,Command-Buttons 和 AJAX 可以在 Head 和 Cells 中使用.
It looks nice, Command-Buttons and AJAX works in both Head and Cells.
这篇关于具有行跨度的 Primefaces 数据表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!