Reputation: 53
I'm sorry if I have to be vague as I can't really show the clients requirement.
I have a stacked ordered list, which shows details of the parent and child. Before the parent and child part, the first item and more item after the parent-child part is showing different details, but I have to put it in the same list. So what I'm trying to achieve is:
But what I got:
<ol type="a">
<li>Coffee</li> //item without child detail
<span class="widget-has-slot">{{the parent-child widget}}<br />
<pre>
<li th:each="parent : ${parentChildMap}"> //parent
//parent detail
<ol> //child list start
<li th:each="child : ${parent.value}"> //child
//child detail
</li> //child closing tag
</ol> //child list end
</li> //parent closing tag
<li>Water</li> //more item without child detail
<li>Beer</li>
</ol>
I tried using counter increment, but it still showing the same result. Reference:
Currently, I'm using 3 different ol with start value. One for the first item, one for the thymeleaf part, and another one after the thymeleaf, which shows me the result I wanted, but I know this is not efficient as I will need to change the start value when the number of parent changed.
<ol type="a"> // first ol
<li>Coffee</li> //item without child detail
</ol>
<span class="widget-has-slot">{{the parent-child widget}}<br />
<pre>
<ol type="a" start="2"> //second ol
<li th:each="parent : ${parentChildMap}"> //parent
//parent detail
<ol> //child list start
<li th:each="child : ${parent.value}"> //child
//child detail
</li> //child closing tag
</ol> //child list end
</li> //parent closing tag
</ol>
<ol type="a" start="5"> //third ol
<li>Water</li> //more item without child detail
<li>Beer</li>
</ol>
How do I get them to work without manually changing start values?
Upvotes: 0
Views: 81
Reputation: 20487
Use th:start
, and calculate the start dynamically.
<ol type="a" th:start="${2 + #lists.size(parentChildMap)}">
Upvotes: 1