Default Sort order for Apex VisualForce Page. - Answers - Salesforce Trailblazer Community
Trailblazer Community
Ask Search:
John GrafJohn Graf 

Default Sort order for Apex VisualForce Page.

I found a perfect App from Salesforce Labs that makes life easier for my Sales Team, Mass Update And Mass Edit From List View.  They use this to edit a huge number of child records to a custom object.  The app allows them to edit key fields of those records from one page.  The problem I am having is the sort order.  The order as it generated is in no valuable order.  Is there a way to have the list generate in a default order.
From my limited experience in Apex (or Coding at all for that matter) I see that the page uses a standard controller that is organized in the order:

form – pageBlock – pageBlockTable – Columns1-7

I want to specify one of the columns to dictate the sort order of the table.  I have discussed this issue with people with code writing experience outside the Apex world and they say this should be a rather easy fix.  IS that true or am I looking into a complicated fix?
Marco (werewolf) CasalainaMarco (werewolf) Casalaina
The sort order is generally defined by the controller that feeds the page its data.  So you'll want to look at what the controller is first (which is Apex, not Visualforce, so no pageBlock or anything like that there) and see if there's somewhere in there that you can add an ORDER BY to a query.
Chris WhiteheadChris Whitehead
Hi Jeff,

Were you able to get anything to work?  I am coming against the same problem.  I have a custom object that I extended the app to and just want to sort it by name.  Let me know if you had any luck.

John GrafJohn Graf
I have still yet to find a solution to my sort order problem.  If you figure something out, let me know.