VF Page:
<apex:page standardController="Contact" extensions="AggregateController">
<apex:form >
<script>
function displayErr(){
sendredirect();
}
</script>
<apex:pageBlock >
<apex:pageBlockTable value="{!resellerlist}" var="o">
<apex:column >
<apex:facet name="header">Account Name</apex:facet>
{!o['name']} </apex:column>
<apex:column >
<apex:facet name="header">No of contacts</apex:facet>
<apex:outputLink onclick="dislayErr()">{!o['ids']}</apex:outputLink> </apex:column>
</apex:pageBlockTable>
<apex:outputLink ></apex:outputLink>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller:
public with sharing class AggregateController {
public List<AggregateResult> groupedResults{get; set;}
//public string searchstring{get;set;}
public Integer total_used{get;set;}
//public list<Contact> listcon{get; set;}
public AggregateController(ApexPages.StandardController controller) {
groupedResults=[Select Account.Name name, Count(Id) ids From Contact Group By Account.Name limit 100];
system.debug('groupedResults'+groupedResults[0]);
}
public list<AggregateResult> resellerlist {
get { return groupedResults;}
}
public PageReference sendredirect(){
return null;
}
/*public PageReference search(){
groupedResults=[SELECT COUNT(Id) FROM Contact, Contact.Account ];
listcon=[select LastName from Contact where Account.Name=:searchstring];
system.debug('listcon'+listcon);
system.debug('groupedResults'+groupedResults);
total_used = Integer.valueOf(groupedResults[0].get('expr0') + '');
system.debug('total_used '+total_used );
return null;
}*/
}
hi i made an attempt to show each account with number of contacts, if i click on count it has to redirect to account detail page, here i had used list
///please suggest me what to do