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
punnoosepunnoose 

list to columns in a table

I  two lists  list a and  list b

i am able to display a table like this

 

Column1   Column2

a,b,c             e,f,h

 

where a,b,c are contents of list a and e,f,h are contents of list b

How do i make it to

Column1   Column2

a                      e

b                        f

c                        h

 

 

This is a long stanging requiement of mine with<ape:columns>

 

Regards

Punnoose

Noam.dganiNoam.dgani

Hi,

 i'm assuming the lists are the same size if you want to display them in parallel.

 

Create an inner class in you controller/extension that looks something like this:

 

public class innerClass{

 

public string(?) valA{get;set;}

public string(?) valB{get;set;}

}

 

then do something like:

 

List<innerClass> lst = new List<innerClass>();

 

for(Integer i = 0;i < listA.size(); i++)

{

innerClass ic = new innerClass();

ic.valA = listA[i];

ic.valB = listB[i];

}

 

and in your VF page set the 'lst' of innerClass instances as your value.

 

if more elaboration is needed, feel free to ask.

 

Regards

 

 

punnoosepunnoose

I need some more elaboration regarding this. i am in a fix with this

Please do reply

Regards

Punnoosre

Eugene PozniakEugene Pozniak

Try this:

 

controller:

public with sharing class TableController {
	public List<yourType> firstColumn { get; set; }
	public List<yourType> secondColumn { get; set; }
	
	public TableController() {
		// init your lists
	}
}

 

page:

<apex:page controller="TableController">
	<apex:form >
		<apex:pageBlock >
			<apex:pageBlockSection columns="2">
				<apex:pageBlockSection columns="1" title="first">
					<apex:repeat value="{!firstColumn}" var="first">
						<!-- Show that you need -->
					</apex:repeat>
				</apex:pageBlockSection>
				
				<apex:pageBlockSection columns="1" title="second">
					<apex:repeat value="{!secondColumn}" var="second">
						<!-- Show that you need -->
					</apex:repeat>
				</apex:pageBlockSection>
			</apex:pageBlockSection>
		</apex:pageBlock>
	</apex:form>
</apex:page>