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
DavidDDavidD 

Can I put apex code inside apex:page to create dynamic HTML table?

Hi,
 
I am new to Visualforce, this may be a stupid question. what we'd like to achive is to create a dynamic HTML table, this table has dynamic columns.
e.g.
1 The number of columns for this HTML table will be the number of VF users in our organization.
2.The title for each column will be the user's full name in our organization.
3. and the data for each row will contain some kind of data for all users in our organization.
 
I was wondering how to create this dynamic HTML table using VF.
 
Any ideas or help would be much appreciated!
 
Thanks in advance.
 
Best Regards,
 
David
ShamSham
Since columns is not Bindable property for all table type containers in VF
you have to rely heavily on apex:Repeat to achieve this.

eg.

Code:
<table>
<tr>
<apex:Repeat value={!User} var="user">
  <td>{!user.Name}</td>
</apex:Repeat>
</tr>
<tr>
  <apex:Repeat value={!User} var="user">
    <td>{!user.Email}</td>
  </apex:Repeat> 
</tr>
</table>

 

DavidDDavidD
Hi Sham,

Thank you so much, I'll try it out. I believe it should work.

Thanks again.

Regards,

David