+ Start a Discussion
SurekaSureka 

How to display History Related lists in descending order in Visualforce?

Hi All,

 

I am displaying History Related lists in Visualforce using the below code:

 

 

<apex:dataTable value="{!Object.histories}" var="history" rowClasses="odd,even" cellspacing="15" width="100%">
            <apex:column >
                <apex:facet name="header"></apex:facet>
                <apex:facet name="footer"></apex:facet>
                <apex:outputText value="{0,date,MM/dd/yyyy HH:mm }">
                <apex:param value="{!history.createddate}" />
                </apex:outputText>
            </apex:column>
            <apex:column >
                <apex:facet name="header">Field</apex:facet>
                <apex:facet name="footer"></apex:facet>
                <b> <apex:outputText value="{!history.field}"/></b>
                </apex:column>
            <apex:column >
                <apex:facet name="header">Editied By</apex:facet>
                <apex:facet name="footer"></apex:facet>
                <apex:outputText value="{!history.createdby.name}"/>
            </apex:column>
            <apex:column >
                <apex:facet name="header">Old Value</apex:facet>
                <apex:facet name="footer"></apex:facet>
                <apex:outputText value="{!history.oldvalue}"/>
            </apex:column>
            <apex:column >
                <apex:facet name="header">New Value</apex:facet>
                <apex:facet name="footer"></apex:facet>
                <apex:outputText value="{!history.newvalue}"/>
            </apex:column>
        </apex:datatable>

 

 

The history table is appearing in the ascending order(ie, "Created" is coming first, followed by the other field trackings).

 

But I need to display descendingly (by Created Date).

 

Any Suggestions?

 

Thanks

Bhuvana

DaveHagmanDaveHagman

Are you using a controller extension? If you are you could always Select all of your objects into a list in your controller (Either in sorted order or sort them after the fact) and call that list into your dataTable.

Ispita_NavatarIspita_Navatar

  There is no sorting attribute available in any Standard Apex Tables(apex:dataTable, apex:pageTableBlock,apex:repeat).

 So to implement sorting in Apex table you need to use a controller and get the list data on header click in Asc or Desc order  then rerender the Apex Table. The other way to do this is Use Active widget, the sorting functionality is already implemented there.

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.

 

 

SurekaSureka
Hi, Since I am not using any controller, I would require a solution that processes the list in the VF page itself.Can you please elaborate on Active Widget? Will it work without the controller? Thanks