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
amorganamorgan 

How do I display Opportunities by User?

I want to display something like this:


  • User 1:
    • Opportunity 1
    • Opportunity 2
  • User 2:
    • Opportunity 3
    • Opportunity 4

Here is the Page code I'm trying to use:



<apex:page controller="myController">
<apex:pageBlock title="Opportunities by User">
<apex:dataList value="{!users}" var="user">
<apex:pageBlockSection title="{!user.firstname}">
<apex:dataTable value="{!XXX what do I put here? XXX}" var="opp">
<apex:column >{!opp.name}</apex:column>
</apex:dataTable>
</apex:pageBlockSection>
</apex:dataList>
</apex:pageBlock>
</apex:page>


Here is the Controller Code:



public class myController {

public List getUsers() {
return [select firstname from user];
}

public List getOppsForUser(User user) { // How can I use this method?
return [select name from opportunity where ownerid=:user.id];
}

}
amorganamorgan
I found my answer in this thread