• pixel1024
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies

I'm trying to show or hide a <tr> HTML tag inside an apex:repeat, but can't find a way where SFDC will save the code without error. Basically I'm building a table and want to start a new <tr> if a certain condition is met (item number mod 3 = 0, so create a new row when the table row has three cells). Attached is a simplifed example, but it shows what I'm trying to do.

 

Note: I can't use an apex:panelGroup because I have nested repeaters in each "column".

 

Thanks!

 

Controller:

public with sharing class TestBuildTable {
	public List<Integer> Ints {get;set;}
	
	public TestBuildTable() {
		this.Ints = new List<Integer>();
		for (Integer i=0; i<20; i++) {
			this.Ints.add(i);
		}
	}
}

 

VF page first try (fail):

<apex:page id="TestBuildTable" Controller="TestBuildTable">
  <table>
    <apex:repeat value="{!Ints}" var="int">
	  {!IF(MOD(int,3)==0,'<tr>',' ')}
	    <td>{!int} nested repeat here</td>
	  {!IF(MOD(int,3)==0,'</tr>',' ')}
	</apex:repeat>
  </table>
</apex:page>

 

VF page second try (fail):

<apex:page id="TestBuildTable" Controller="TestBuildTable">
  <table>
    <apex:repeat value="{!Ints}" var="int">
	  <apex:outputPanel rendered="{!MOD(int,3)==0}" layout="none"><tr></apex:outputPanel>
	    <td>{!int}</td>
	  <apex:outputPanel rendered="{!MOD(int,3)==0}" layout="none"></tr></apex:outputPanel>
	</apex:repeat>
  </table>
</apex:page>

 

The desired result is a table that looks like this:

1    2    3

4    5    6

7    8    9

10 11 12

13 14 15

I'm trying to show or hide a <tr> HTML tag inside an apex:repeat, but can't find a way where SFDC will save the code without error. Basically I'm building a table and want to start a new <tr> if a certain condition is met (item number mod 3 = 0, so create a new row when the table row has three cells). Attached is a simplifed example, but it shows what I'm trying to do.

 

Note: I can't use an apex:panelGroup because I have nested repeaters in each "column".

 

Thanks!

 

Controller:

public with sharing class TestBuildTable {
	public List<Integer> Ints {get;set;}
	
	public TestBuildTable() {
		this.Ints = new List<Integer>();
		for (Integer i=0; i<20; i++) {
			this.Ints.add(i);
		}
	}
}

 

VF page first try (fail):

<apex:page id="TestBuildTable" Controller="TestBuildTable">
  <table>
    <apex:repeat value="{!Ints}" var="int">
	  {!IF(MOD(int,3)==0,'<tr>',' ')}
	    <td>{!int} nested repeat here</td>
	  {!IF(MOD(int,3)==0,'</tr>',' ')}
	</apex:repeat>
  </table>
</apex:page>

 

VF page second try (fail):

<apex:page id="TestBuildTable" Controller="TestBuildTable">
  <table>
    <apex:repeat value="{!Ints}" var="int">
	  <apex:outputPanel rendered="{!MOD(int,3)==0}" layout="none"><tr></apex:outputPanel>
	    <td>{!int}</td>
	  <apex:outputPanel rendered="{!MOD(int,3)==0}" layout="none"></tr></apex:outputPanel>
	</apex:repeat>
  </table>
</apex:page>

 

The desired result is a table that looks like this:

1    2    3

4    5    6

7    8    9

10 11 12

13 14 15