I need to create a data table that contains Task and Opportunity data, but puts them together in the same table that uses days of the week for column headers. Example below - I've never seen a way to iterate over two different objects in the same table, anyone done this before? Is there a way to create two PageBlockTables but have them appear right above/below each other to create the same effect?
1 Answer
No, things like apex:dataTable and apex:panelGrid won't generate this kind of table for you. You need to do it yourself.
<table>
<thead>
<th>User</th>
<th>Monday</th>
<th>Tuesday</th>
<th>Wednesday</th>
<th>Thursday</th>
<th>Friday</th>
</thead>
<tbody>
<apex:repeat items="{!userdata}" var="data">
<tr><td colspan="6">Tasks for {!data.name}</td></tr>
<tr>
<td># of Tasks</td>
<td>{!data.mondayTasks}</td>
<td>{!data.tuesdayTasks}</td>
<td>{!data.wednesdayTasks}</td>
<td>{!data.thursdayTasks}</td>
<td>{!data.fridayTasks}</td>
</tr>
<tr><td colspan="6">Accounts for {!data.name}</td></tr>
<tr>
<td># of Tasks</td>
<td>{!data.mondayAccounts}</td>
<td>{!data.tuesdayAccounts}</td>
<td>{!data.wednesdayAccounts}</td>
<td>{!data.thursdayAccounts}</td>
<td>{!data.fridayAccounts}</td>
</tr>
</apex:repeat>
</tbody>
</table>
This also means you'll need a wrapper object, and some maps to associate all the data together. The above code should give you a starting point, you just need the Apex from here.