gpt4 book ai didi

jquery - Spring Boot Dandelion 数据表 Thymeleaf 日期之间的搜索

转载 作者:行者123 更新时间:2023-12-01 00:30:31 25 4
gpt4 key购买 nike

我是带有 Spring Boot 和 thymeleaf 的 Dandelion 数据表。

这是我想要显示所有日志的表的代码。

<table class="table table-bordered" id="expiredUsersTable" dt:table="true">
<thead>
<tr>
<th dt:sortInitDirection="desc">TIME</th>
<th dt:filterable="true" dt:filterType="select">Log Level</th>
<th>Message</th>
</tr>
</thead>
<tbody>
<tr th:each="log : ${logs}">
<td th:text="${log?.getFormattedDate()}"></td>
<td th:text="${log?.level}"></td>
<td th:text="${log?.message}"></td>
</tr>
</tbody>
</table>

我想在该表的日期范围之间添加过滤器,但我无法使用蒲公英数据表实现此目的。有哪些方法可以做到这一点?

最佳答案

在 thymeleaf 中,这看起来像这样:

Controller :

// Create these dates however you want, these example dates are filtering between 1950 and 1960.
GregorianCalendar gc = new GregorianCalendar();
gc.set(Calendar.YEAR, 1950);
model.put("start", gc.getTime());

gc.set(Calendar.YEAR, 1960);
model.put("end", gc.getTime());

thymeleaf :

<table class="table table-bordered" id="expiredUsersTable" dt:table="true">
<thead>
<tr>
<th dt:sortInitDirection="desc">TIME</th>
<th dt:filterable="true" dt:filterType="select">Log Level</th>
<th>Message</th>
</tr>
</thead>

<tbody>
<tr th:each="log : ${logs}" th:unless="${log.date.before(start) OR log.date.after(end)}">
<td th:text="${log?.formattedDate}"></td>
<td th:text="${log?.level}"></td>
<td th:text="${log?.message}"></td>
</tr>
</tbody>
</table>

关于jquery - Spring Boot Dandelion 数据表 Thymeleaf 日期之间的搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41893670/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com