+ Start a Discussion

Rendering Child Object From List Controller

How do you render a subquery from a custom list controller?  I want to render fields from ActivityHistories for the current account.  ***I also need to have pagination.***




Here is my current code:



public class ActivityHistorySetConExt {

        //ApexPages.StandardSetController must be instantiated for standard list controllers
        public ApexPages.StandardSetController setCon {
        get {
            if(setCon == null) {
                setCon = new ApexPages.StandardSetController(
                      	[select id, name, ownerid,
							(select subject, whoid, whatid, accountid, ownerid, activitydate, description from ActivityHistories 
							 order by activitydate desc
							 limit 1000)
						from account
						where id = :ApexPages.currentPage().getParameters().get('id')]
            return setCon;
    // Initialize setCon and return a list of records  
    public List<Account> getAccounts() {
         return (List<Account>) setCon.getRecords();
    // returns the next page of records
 	public void first() {
 	// returns the next page of records
 	public void last() {
    // indicates whether there are more records before the current page set.
	public Boolean hasPrevious {
		get {
			return setCon.getHasPrevious();
	// returns the previous page of records
 	public void previous() {
    // indicates whether there are more records after the current page set.
	public Boolean hasNext {
		get {
			return setCon.getHasNext();
	// returns the next page of records
 	public void next() {





Thanks but that doesn't solve the pagination problem.  


Next and Previous methods are returning as null so it's not possible to view all of the activityhistories list, which is needed.


Here is VF page which is not returning all activityhistories....


<apex:page controller="ActivityHistorySetConExt">
    <apex:form id="theForm">
        <apex:pageBlock title="Viewing List">
            <apex:repeat value="{!accounts}" var="a">
                <apex:pageBlockTable value="{!a.activityhistories}" var="hist">
                    <apex:column value="{!hist.subject}" />
                    <apex:column value="{!hist.accountid}" />
                    <apex:column value="{!hist.ownerid}" />
        <apex:panelGrid columns="4">
            <apex:commandLink action="{!first}">First</apex:commandlink>
            <apex:commandLink action="{!previous}" rendered="{!hasPrevious}">Previous</apex:commandlink>
            <apex:commandLink action="{!next}" rendered="{!hasNext}">Next</apex:commandlink>
            <apex:commandLink action="{!last}">Last</apex:commandlink>





There is no mechanism to get the pagination controls for child objects currently.


This is an unfortunate but known limitation.


Thank you for your post mtbclimber.


As I understand it, the Task object can not be called from a List Controller.  Currently, is there any workaround to create pagination for the task object?  


Basically what is needed is a VF page which returns account activities assigned to certain users with pagination.  I've already created a VF page that returns account activities assigned to certain users but some accounts have hundreds and hundreds of records which makes the page very very slow and almost useless.  Pagination on the Task object is badly needed.