+ Start a Discussion
Tin013Tin013 

Ordering the display in apex:datatable

Hi all,
 
I have a visual page with following code. It works fine but wondered if there is a way I can dictate how the the order in which data are being displayed? At the moment, it is displaying by the order in which it has gone into the system. I would like the data to be displayed by Child Name (Ascd) and by Club Date (ASCD).
 
Is there a way to minapulate the data display in datatable? 
 
 
<apex:page standardController="Opportunity" standardStylesheets="true" showHeader="false" sidebar="false" tabStyle="Opportunity">

<apex:datatable cellpadding="4" Cellspacing="1" border="1" style="border-color:black;" var="cx" value="{!Opportunity.Booking_Line_Items__r}">

<apex:column >

<apex:outputText value="{!cx.Child_Name_Text__c}" style="font-size:12px"/>

<apex:facet name="header"><font style="font-size:12px">Name of child</font></apex:facet>

</apex:column>
<apex:column >
<apex:outputText value="{0,date,dd/MM/yyyy}" style="font-size:12px">
<apex:param value="{!cx.DOB__c}" />
</apex:outputText> 
<apex:facet name="header"><font style="font-size:12px">Date Of Birth</font></apex:facet>
</apex:column>
<apex:column >
<apex:outputText value="{0,date,dd/MM/yyyy}" style="font-size:12px">
<apex:param value="{!cx.Club_Date__c}" />
</apex:outputText>  
<apex:facet name="header"><font style="font-size:12px">Date(s) Booked In</font></apex:facet>
</apex:column>
<apex:column >
<apex:outputText value="{!cx.Status__c}" style="font-size:12px"/>
<apex:facet name="header"><font style="font-size:12px">Status</font></apex:facet>
</apex:column>
</apex:datatable>

</apex:page>
 
Many thanks, 
Anand@SAASAnand@SAAS
You will have to write an extension that uses SOQL and ORDER BY to sort it in the right order or do in memory sort. Why don't you use <apex:relatedList> instead that allows you to leverage the sorting defined in the config.
Tin013Tin013

Hi Anand,

 

Thanks for your reply. It is quite complicated than I had imagined. I don't know have the necessary expertise to write such extension.

 

With regards to relatedList, it might not be a good solution purely because this page is to use as an email template so I can't have Action column and hyperlinks on the related list section...

 

Thanks,