You need to sign in to do that
Don't have an account?
Vincent Drader 2
Sorting a visualforce table (pdf output)
Nonprofit admin moonlighting as a developer here. I have a visualforce page that has a table I would like to sort by one of the columns A to Z. The visualforce page is just a pdf print out of certain things from the object and related lists. See below for the snippet of code I have for my table. How can I sort the table A-Z by "Latin Tree Name" column, which takes the {!tr.Tree_Name__r.Name} values?
<table width="100%" border="1">
<th width="15%">CRM Record #</th><th width="35%">Latin Tree Name</th><th width="15%">Stock Type</th><th width="17%">Form</th><th width="10%">Size</th><th width="8%">Quantity</th>
<apex:repeat value="{!Campaign.Tree_Records__r}" var="tr">
<tr>
<td><apex:outputtext value="{!tr.Name}" /></td>
<td><apex:outputtext value="{!tr.Tree_Name__r.Name}" /></td>
<td>{!tr.Stock_Type__c}</td>
<td>{!tr.Tree_Form__c}</td>
<td>{!tr.Caliper_Size__c}</td>
<td>{!ROUND(tr.Quantity_Requested__c,0)}</td>
</tr>
</apex:repeat>
</table>
<table width="100%" border="1">
<th width="15%">CRM Record #</th><th width="35%">Latin Tree Name</th><th width="15%">Stock Type</th><th width="17%">Form</th><th width="10%">Size</th><th width="8%">Quantity</th>
<apex:repeat value="{!Campaign.Tree_Records__r}" var="tr">
<tr>
<td><apex:outputtext value="{!tr.Name}" /></td>
<td><apex:outputtext value="{!tr.Tree_Name__r.Name}" /></td>
<td>{!tr.Stock_Type__c}</td>
<td>{!tr.Tree_Form__c}</td>
<td>{!tr.Caliper_Size__c}</td>
<td>{!ROUND(tr.Quantity_Requested__c,0)}</td>
</tr>
</apex:repeat>
</table>
You can also use the Query Editor tab of the Developer Console (Set up -> Developer Console) to test out the query before adding it to your query.