loop through 2 items using g:each in grails

Can I loop through more than 1 item in g:each tag in grails? I want to simultaneously loop through 2 items of same length and then display the response.

Any help on this is appreciated.

Upvotes: 1

Views: 906

Answers (1)

Mike B
Mike B

Reputation: 2776

Yes, you can.
You can use status to know which loop it is and which element to grab.

<g:each in="${firstList}" status="i" var="elem">                
   <td>${secondList[i].attribute}</td> //you can access 2nd list elements like this
   <td>${elem.attribute}</td> //you can access first list elements like this
</g:each> 

Upvotes: 3

Related Questions