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

Sorting, Paging, and Ordering Custom Related Lists on an Account Page

I'm trying to setup a custom related list on the Account page that has sorting and pagination, but without losing too much of the standard functionality for the page.


So my questions are:

1. Is there a way to reorder the related lists so that the custom list is not at the bottom of all the others? I've tried moving it with javascript but when someone does inline editing then the related lists are rerendered without the custom list. I've also tried using <apex:relatedlist> tags for the other related lists, but then they do not hide/appear for the right page layouts/record types.

2. What's the easiest way to add sorting and pagination? The users would like to be able to click on a column and have it resort.


Visualforce Page

<apex:page standardcontroller="Account" extensions="AccountDetailController" tabStyle="Account" id="AccountPage">

<apex:detail id="detail" relatedListHover="false" inlineedit="true" />

<!-- Active Licenses --> <apex:pageblock title="Active Licenses" id="licenses" > <apex:facet name="header"> <table border="0" cellpadding="0" cellspacing="0" style="padding:0;border-bottom:none;"><tbody><tr> <td class="pbTitle"><img src="/img/icon/cd24.png" alt="License" class="relatedListIcon" style="width:24px; display:block; margin:-4px 4px -5px -8px;" title="License"/><h3 >Active Licenses</h3></td> <td class="pbButton"><input value="New License" title="New License" class="btn" onclick="window.location.href='{!URLFOR($Action.License__c.New, $ObjectType.License__c,['CF00Na000000A8Imu'=Account.Name,'CF00Na000000A8Imu_lkid'=Account.Id,'retURL'='/'+Account.Id])}';return false;" type="button" style="padding:2px 3px;"/></td> <td class="pbHelp">&nbsp;</td> </tr></tbody></table> </apex:facet> <apex:pageblocktable title="Active Licenses" id="activelicenses" value="{!Licenses}" var="license" rendered="{!Licenses.size!=0}" > <apex:column headerValue="Name"> <apex:outputlink value="/{!License.Id}" target="_parent" ><apex:outputfield value="{!license.Name}"/></apex:outputlink> </apex:column> <apex:repeat value="{!$ObjectType.License__c.FieldSets.Account_Related_List}" var="f"> <apex:column value="{!license[f]}" /> </apex:repeat> </apex:pageblocktable> <apex:outputText rendered="{!Licenses.size = 0}" value="No records to display" style="padding:5px;border:1px solid #E0E3E5;display:block;" /> </apex:pageblock>




Thank you, those are good examples of pagination. Has anyone done sorting and pagination in visualforce? It's unclear whether standardsetcontroller has issues with sorting to begin with.

Mohan Raj 33Mohan Raj 33
@Paul.Fox Hi, Can You solve that case of in standardset controller with sorting and pagination in visualforce(both together)? if it's done plz send the code to me it's my task noe it's really helpful to me.Thanks in advance, Mohan