+ 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