You need to sign in to do that
Don't have an account?

No data to display in VF
Ok, so trying to print a table from one (1) list, normally this in a single column, but I am trying to get it in three (3) columns that are (3) three rows deep. I am not getting an error, but I am not getting any values either.
VF
<apex:page controller="MyController" >
<head>
</head>
<apex:form >
<apex:pageBlock >
<apex:pageBlockTable value="{!MyWrappers}" var="wrap">
<apex:column headerValue="Col 1">
<apex:outputField value="{!wrap.myAcc1.Name}"/>
</apex:column>
<apex:column headerValue="Col 2">
<apex:outputField value="{!wrap.myAcc2.Name}"/>
</apex:column>
<apex:column headerValue="Col 3">
<apex:outputField value="{!wrap.myAcc3.Name}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller
public class MyController {
public List<MyWrapper> myWrappers{get; set;}
public class MyWrapper
{
public Account myAcc1 {get; set;}
public Account myAcc2 {get; set;}
public Account myAcc3 {get; set;}
public Boolean checkbox1 {get; set;}
public Boolean checkbox2 {get; set;}
public Boolean checkbox3 {get; set;}
}
public MyController()
{
myWrappers=new List<MyWrapper>();
Integer idx=0;
MyWrapper wrap;
for (Account acc: [select id, Name from Account limit 12])
{
if (0==Math.mod(idx, 3))
{
wrap=new MyWrapper();
wrap.myAcc1=acc;
if (1==Math.mod(idx, 3))
wrap.myAcc2=acc;
else if (2==Math.mod(idx, 3))
wrap.myAcc3=acc;
}
}
}
}
Hi Jerry,
It seems like you are holding the records in wrap object but not actually adding them to the Main wrapper class list which you are displaying in the Visualforce page.
Also there seems to be problem in logic, I think you need to show the records in alternate columns, if it is then update your controller as below:
Kindly test this code and let me know what didn't worked.