+ Start a Discussion
xnerd00xxnerd00x 

OpportunityLineItemSchedule - sorting the list

Hey all,

I have a VF page that has a pageBlockTable section that iterates over all the OpportunityLineItemSchedules for a given OpportunityLineItem.  I would figure that this would sort by the ScheduleDate, but that isn't happening.

 

I was just wondering what controls the sorting for a pageBlockTable section?

 

I got this from the VF developer's guide, but not sure what it means by "current view".  Can anyone enlighten me?

When you are using a standard list controller, the returned records sort on the frst column of data, as defned by the current view, even if that column is not rendered.When you use an extension or custom list controller, you can control the sort method.

 

Here's my very simple code:

 

<apex:pageBlock title="Schedule">
<apex:pageBlockTable value="{!OpportunityLineItem.OpportunityLineItemSchedules}" var="sch" rows="100">
<apex:column value="{!sch.ScheduleDate}"/>
<apex:column value="{!sch.Revenue}"/>
<apex:column value="{!sch.Description}"/>
</apex:pageBlockTable>
</apex:pageBlock>

 

 Oh, and in addition, the out of the box related list *does* show the sort order that I'm looking for.

 

Message Edited by xnerd00x on 04-02-2009 12:35 PM
JimRaeJimRae

The only way I have been able to do this is to create a custom list and sort it manually in a custom controller.

There are some samples on the board about creating a map using the sort field as the key, and then sorting the keys, then creating a new list based on the sorted keys.  Look for map sort list.

 

 

xnerd00xxnerd00x

Yeah - after doing some more research, I just created an extension class where I create my own list of schedules and use an order by clause.  Thanks for the suggestion!

 

 

public class LineItemExtension { private final OpportunityLineItem oli; public LineItemExtension(ApexPages.StandardController controller) { this.oli = (OpportunityLineItem) controller.getRecord(); } public List<OpportunityLineItemSchedule> getSchedules() { return [select scheduleDate, Revenue, description from OpportunityLineItemSchedule where OpportunityLineItemId = :this.oli.Id order by scheduleDate]; } }

 

 

 

Mohammad Alazzouni 6Mohammad Alazzouni 6
We need to do this as well but can't create extensions because of Pro Edition Limitations. Is there a way to view OpportunityLineItemSchedule and have it broken down by Calendar Quarters?