You need to sign in to do that
Don't have an account?
Sureka
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
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.
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.