+ Start a Discussion
Chad RitchieChad Ritchie 

Sorting Visualforce DataTable

Is it possible to sort the following with just a standard controller? I'd really like to sort by Product__r.Name, but would really like to keep it within Visualforce. 
<apex:dataTable value="{!Contact.Positions__r}" var="b" rules="all" columns="3" columnsWidth="250px,250px" align="left"
            columnClasses="columnBorders" cellpadding="5px" cellspacing="0">
             <apex:facet name="header">ACTIVE POSITIONS</apex:facet> 
                     <apex:column value="{!b.Product__r.Name}" headerValue="Product" rendered="{!b.isactive__c}"/>
                     <apex:column value="{!b.Name}" headerValue="Account Name" rendered="{!b.isactive__c}"/>
                     <apex:column value="{!b.Balance__c}" headerValue="Balance" rendered="{!b.isactive__c}"/>

ShirishaShirisha (Salesforce Developers) 
Hi Chad,


I don't think it is possible.However,you can achieve this by using the controller/extension.

Please find the sample code below:



Kindly let me know if it helps you and close your query by marking it as best answer so that it can help others in the future.

Warm Regards,
Shirisha Pathuri