0

I have a very simple Visualforce page here that is showing a related list of Activities__r related to an Account. The issue is that I want to sort these Activites by their due date. I know how to do this using an extension in Apex, but this instance is Professional so I am unable to write the extension. I have been looking around and cannot find another way to do this. Any advice?

Here is the Visualforce Page:

<apex:page standardController="Account">
<apex:pageBlock >
    <apex:pageBlockTable value="{!account.Activities__r}" var="task">
        <apex:column value="{!task.Description}"/>
        <apex:column value="{!task.Subject}"/>
        <apex:column value="{!task.ActivityDate}"/>
        <apex:column value="{!task.WhoId}"/>
    </apex:pageBlockTable>
</apex:pageBlock>

2
  • You might want to look at Javascript.
    – Adrian Larson
    Aug 1, 2017 at 14:46
  • That is what I was leaning towards, I just got this updated with some Javascript and got it working.
    – cmmoutes13
    Aug 1, 2017 at 14:52

1 Answer 1

0

I used some script to resolve this issue. It does not set the default sorting, but it allows me to sort the related list by whatever column I want by clicking the header of that column. The new Visualforce page is listed below.

<apex:page standardController="Account">
<apex:includeScript value="//code.jquery.com/jquery-2.1.1.min.js"/
<apex:includeScript value="//cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.18.3/js/jquery.tablesorter.js"/>
<apex:includeScript value="//cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.18.3/js/jquery.tablesorter.widgets.js"/>
<apex:stylesheet value="//cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.18.3/css/theme.jui.css"/>
<script>
$(document).ready(function(){
    $("table").tablesorter({

    theme : 'jui', 

    headerTemplate : '{content} {icon}',

    widgets : ['uitheme', 'zebra'],

    widgetOptions : {
      zebra   : ["even", "odd"],
    }
});
});
</script>
<apex:pageBlock >
    <apex:pageBlockTable value="{!account.Activities__r}" var="task" style="font-size:100%;">
        <apex:column value="{!task.Description}"/>
        <apex:column value="{!task.Subject}"/>
        <apex:column value="{!task.ActivityDate}"/>
        <apex:column value="{!task.WhoId}"/>
    </apex:pageBlockTable>
</apex:pageBlock>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .