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
PharaohgirlPharaohgirl 

Could you please help with my (non-working) controller extension to sort a table?

I need to define an automatic fixed sort order for a table in a Visualforce page without using javascript (so no Tablesorter) as I need to use renderasPDF.

My main custom object is Rulecloseout__c.

Then I have Project_team__c which is connected via a Master-Detail relationship to Rulecloseout__c [field name Rule_closeout_report__c] and Contact [field name Contact__c].

This is the code I currently have on my Visualforce page, which shows the fields I want, but doesn’t sort the table. I want to sort by the Role__c field.
 
<br></br><apex:pageBlockSection title="Project team"> </apex:pageBlockSection>
<apex:pageblocktable style="width:720px" border="1" cellpadding="4" value="{!Rulecloseout__c.Project_teamsrel__r}" id="projectteam" var="rcpt" >
    <apex:column style="width:150px" value="{!rcpt.Contact__r.Full_Name__c}" />
    <apex:column style="width:200px" value="{!rcpt.Role__c}" />
    <apex:column style="width:370px" value="{!rcpt.Notes__c}" />
</apex:pageblocktable>

I have tried making a controller extension to sort the table, but haven’t got very far. I’m not even sure if I’ve got the right object in my extension, or if it should be Project_team__c.

And I’m also getting an error message: Missing “ at ‘select’
 
public with sharing class TableOrder {
    private final Rulecloseout__c ruco;
    public TableOrder(ApexPages.StandardController stdController) {
        this.ruco = (Rulecloseout__c)stdController.getRecord();}
} select Contact__c from Project_team__c ORDER BY Role__c ASC
}
}

Could anyone please point me in the right direction?
 
Thanks,

Rowena