0

do you know how to sort data in an apex:pageBlockTable in a simple way (i am starting visualforce developments).

I use the standard account controller for this page. Thanks!

here is an example, i want to sort the related opportunities for this VF page generated via a button from every SF account:

 <apex:pageBlock >  
    <apex:pageBlockSection title="Opportunities" collapsible="false">
       <apex:pageBlockTable value="{!Account.opportunities}" var="opportunity" border="1px solid black" cellpadding="3" rowClasses="alldatarows">
           <apex:column value="{!opportunity.StageName}" style="padding: 7px;order-bottom: 1px solid ddd;border: 1px solid black;"/>
           <apex:column value="{!opportunity.Amount}" style="padding: 7px;order-bottom: 1px solid ddd;border: 1px solid black;"/>
           <apex:column value="{!opportunity.CloseDate}" style="padding: 7px;order-bottom: 1px solid ddd;border: 1px solid black;"/>
        </apex:pageBlockTable>
    </apex:pageBlockSection>

</apex:pageBlock>
2
  • You will need either JavaScript or Apex. You can't sort using only the standard controller.
    – sfdcfox
    Commented Apr 26, 2022 at 16:33
  • Personally, I recommend against investing time learning Visaulforce. Its use cases at this point are fairly niche. Learn Lightning Web Components instead.
    – Adrian Larson
    Commented Apr 26, 2022 at 16:38

1 Answer 1

1

Please check Jquery based approaches Refer the link below. As Adrian mentioned on the comment a better approach is LWC. Sorting apex:pageblocktable

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .