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

Alternate populate columns in visualforce
Hi Experts,
I'm trying to alternately populate the columns in my visualforce page with the Account Records. I'm not sure how to do it though.
Here's my page which returns a simple Table with Rows and Columns.
I have the controller named "accountController" which simply contains a list of Accounts.
When I call this in visualforce, it will only return the table below. What I would like to do is to have the first record in the list to go to the 1st column of first row, then the second record go to the second column of first row, then 3rd record goes to the 1st column in the second row and so on. How do I go about it?

Thanks in advance :)
I'm trying to alternately populate the columns in my visualforce page with the Account Records. I'm not sure how to do it though.
Here's my page which returns a simple Table with Rows and Columns.
<apex:page controller="accountController"> <table style="Border:Solid 1px"> <tr> <td style="Border:Solid 1px;background-color:green"> Column 1 </td> <td style="Border:Solid 1px;background-color:green"> Column 2 </td> <td style="Border:Solid 1px;background-color:green"> index </td> </tr> <apex:repeat value="{!wAcc}" var="a"> <tr> <td style="Border:Solid 1px"> <apex:outputText value="{!a.name}"/> </td> <td style="Border:Solid 1px"> </td> <td style="Border:Solid 1px"> </td> </tr> </apex:repeat> </table> </apex:page>
I have the controller named "accountController" which simply contains a list of Accounts.
When I call this in visualforce, it will only return the table below. What I would like to do is to have the first record in the list to go to the 1st column of first row, then the second record go to the second column of first row, then 3rd record goes to the 1st column in the second row and so on. How do I go about it?
Thanks in advance :)
Sometimes, we get issues while rendring as PDF.
I would sugeest you to modify your controller logic a bit
The controller would be - And the Visualforce page would be - Pls let me know, if you have any further issues -
Thanks,
Sumit Kumar Singh
All Answers
You can try this -
It should work fine for you.
Dont forget to mark best answer if it solves your problem.
Thanks,
Sumit Kuamr Singh
I'm newbie so I'm not sure how it worked that way though, could you please explain the lines that you have added for my future reference?
I don't want to copy and paste a code without understanding them..
Thank you very much!
-Zach
<tr>
<td> Account Name
</td>
This block will get rendered when the "counter" is odd. So, this will produce output, something like this -
<td> Account Name
</td>
</tr>
Hope, that helps you.
Thanks,
Sumit Kumar Singh
Thank you so much you're one of the Best!
Thanks,
Sumit Kumar Singh
By the way, I have a follow up question on this approach that you did.
When I do it in a PDF rendered visualforce, it returns me a different result.
Here's the result below.
Thanks
Sometimes, we get issues while rendring as PDF.
I would sugeest you to modify your controller logic a bit
The controller would be - And the Visualforce page would be - Pls let me know, if you have any further issues -
Thanks,
Sumit Kumar Singh