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
guest1231231guest1231231 

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.***

 

Thanks

 

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(
                	Database.getQueryLocator(
                      	[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')]
                      )
				);
            }
            //setCon.SetPageSize(5);
            return setCon;
        }
        set;
    }
    
    // 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() {
 		setCon.first();
 	}
 	
 	// returns the next page of records
 	public void last() {
 		setCon.last();
 	}
    
    // indicates whether there are more records before the current page set.
	public Boolean hasPrevious {
		get {
			return setCon.getHasPrevious();
		}
		set;
	}
	
	// returns the previous page of records
 	public void previous() {
 		setCon.previous();
 	}
    
    // indicates whether there are more records after the current page set.
	public Boolean hasNext {
		get {
			return setCon.getHasNext();
		}
		set;
	}
	
	// returns the next page of records
 	public void next() {
 		setCon.next();
 	}
    
}

 

 

 

guest1231231guest1231231

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:pageBlockTable>
            </apex:repeat>
        </apex:pageBlock>
        <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>
        </apex:panelGrid>
    </apex:form>
</apex:page>

 

 

 

mtbclimbermtbclimber

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

 

This is an unfortunate but known limitation.

guest1231231guest1231231

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.

 

Thanks