[solved] dynamic table in thymeleaf

How to populate a dynamic table in thymeleaf

Solution-1:

<table class=”table table-hover”>

    <tbody>

        <tr th:each=”mr.iterStat : ${list}”>

            <td th:text=”${mrr.id}”></td>

            <td th:text=”${mrr.minAmount}”></td>

            <td th:text=”${mrr.maxAmount}”></td>

        </tr>

    </tbody>

</table>

Solution-2:


<table class=”table table-striped table-primary”>



    <thead class=”ttop”>

        <tr class=”table-info”>

            <td width=”20px”><b> ID</b></td>

            <td><b>NAME</b> </td>

            <td><b>TELEPHONE</b> </td>

            <td><b>SALARY</b> </td>

        </tr>

    </thead>

    <tbody>

        <tr th:each=”empl, iStat : ${emp}” th:style=”${iStat.odd}? ‘font-weight: normal;'”>

            <td width=”20px” th:text=”${empl.id}”>

            </td>
            <td th:text=”${empl.name}”>

            </td>
            <td th:text=”${empl.telephone}”>

            </td>
            <td th:text=”${empl.salary}”>

            </td>
        </tr>

    </tbody>

</table>

Hope it helps

Leave a Reply