+ Start a Discussion

Pre define list column sort order

I need to have couple views with fixed sort order. I do not want the default sort funtionality on some of the list columns.
Example:  My Account List view should display the list sorted by "Region" &  "Created Date". in assending order. The user will edit each record from the top and update information. Based on lastmodified date the record should be pushed down to the view.
Can this be done?   
It's not completely clear what your requirements are but since this is the Apex discussion board, I will assume you are presenting your user with a Visualforce page backed by an apex controller. If that's the case then yes, you can present records in whatever order you see fit. For example, the following code will return an ordered collection of accounts based on what you indicated you needed:

public class accountListCon {
    public List<Account> accounts { 
            if(accounts == null) {
                accounts = [select name, createddate, type from account order by createddate asc, type asc];
            return accounts; 


 And a quick Visualforce page to show the results:

Visualforce Page:
<apex:page controller="accountListCon">
    <apex:pageBlock >
        <apex:pageBlockTable value="{!accounts}" var="account">
            <apex:column value="{!account.name}"/>
            <apex:column value="{!account.createddate}"/>
            <apex:column value="{!account.type}"/>

 How you filter, order and select data for presentation is based on SOQL, the salesforce object query language. For more on the capabilities of SOQL, see the web services API documentation.

Message Edited by mtbclimber on 08-24-2008 05:45 PM