假设我有
Date occuranceDate; //Dates only have years, months, days
String eventOwner;
String eventData;
示例数据:
12-01-2021 , John Doe, random event data 1
12-01-2021, Jane Doe, random event data 2
12-01-2021, Jane Doe, random event data 3
12-02-2021, John Doe, random event data 4
我正在尝试创建一个包含三列事件日期、事件所有者、事件数据
的thymeaf表。这样
对于上面的数据,该表希望
我想创建一个表,显示eventData
的列表,按eventOwner
分组,按发生日期
分组
我正在传递< code >地图
我尝试了以下操作:Thymelaf表的行跨度问题(1个顺序,N篇文章),但这会变得复杂,因为有三个不同的列表示嵌套的映射和列表
您只需一个<code>列表即可完成此操作
<table>
<tr th:each="event, stat: ${events}"
th:with="
newDate=${(stat.index == 0) || (events[stat.index - 1].occuranceDateString != event.occuranceDateString)},
newOwner=${newDate || (stat.index == 0) || (events[stat.index - 1].eventOwner != event.eventOwner)},
" valign="top">
<td th:if="${newDate}" th:text="${event.occuranceDateString}" th:rowspan="${events.?[occuranceDateString == #root.event.occuranceDateString].size()}" />
<td th:if="${newOwner}" th:text="${event.eventOwner}" th:rowspan="${events.?[occuranceDateString == #root.event.occuranceDateString].?[eventOwner == #root.event.eventOwner].size()}" />
<td th:text="${event.eventData}" />
</tr>
</table>