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?

enter image description here


No, things like apex:dataTable and apex:panelGrid won't generate this kind of table for you. You need to do it yourself.

    <apex:repeat items="{!userdata}" var="data">
      <tr><td colspan="6">Tasks for {!data.name}</td></tr>
        <td># of Tasks</td>
      <tr><td colspan="6">Accounts for {!data.name}</td></tr>
        <td># of Tasks</td>

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.