function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Valentin F.Valentin F. 

Dynamically add <tr> each nth element in visualforce

Hello everybody,

I'm trying to display a list of products in a visualforce page that I'm rendering as PDF. 
I already tried a lot of options and figured out the best option could be creating tables. 
<table>
<apex:variable var="i" value="{!0}"/>
<apex:repeat value="{!listProduct}" var="product">
<!--<tr style="display: {!IF((MOD(i,4) == 0), 'table-row', 'none')};">
  <td>
    <table>
      <tr>
        <td>
          <apex:outputText value="{!product.Title}"/>
        </td>
      </tr>
      <tr>
        <td><apex:image width="120" height="50"  value="{!URLFOR(product.image)}"/></td>
      </tr>
    </table>
  </td>  
  <apex:variable var="i" value="{!i+1}"/>
  </apex:repeat>
  </table>
This is my base code to display products. The problem is that it just displays in a single row and I can't dynamically add a <tr> as I get a Salesforce error because </tr> is missing.

I would like to display my products in a new row each n elements.

Any idea ?