0

I have a custom List button that links to a Visualforce page. I want the records selected in the Visualforce page to populate in a certain order. Any suggestions for accomplishing this? I've included my code below:

<apex:page
  standardController="Order_Date__c"
  recordSetVar="unused"
  sidebar="false"
>
  <apex:includeScript value="{!$Resource.UtilJS}" />
  <apex:form>
    <apex:pageBlock>
      <apex:pageMessages />
      <apex:pageBlock>
        Note: All modifications made on the page will be lost if Return button
        is clicked without clicking the Save button first.
      </apex:pageBlock>
      <apex:pageBlockButtons>
        <apex:commandButton value="Save" action="{!save}" />
        <apex:commandButton value="Cancel" action="{!cancel}" />
      </apex:pageBlockButtons>
      <apex:pageBlockTable value="{!selected}" var="a" id="table">
        <apex:column headerValue="Name">
          <apex:outputField value="{!a.name}" />
        </apex:column>
        <apex:column headerValue="Order Start Date">
          <apex:inputField value="{!a.Order_Start_Date__c}" />
        </apex:column>
        <apex:column headerValue="Order End Date">
          <apex:inputField value="{!a.Order_End_Date__c}" />
        </apex:column>
        <apex:column headerValue="Term Length">
          <apex:inputField value="{!a.Term_Length__c}" />
        </apex:column>
        <apex:column headerValue="Allotment">
          <apex:inputField value="{!a.Allotment__c}" />
        </apex:column>
        <apex:column headerValue="Sales Price">
          <apex:inputField value="{!a.Sales_Price__c}" />
        </apex:column>
      </apex:pageBlockTable>
    </apex:pageBlock>
  </apex:form>
</apex:page>

1 Answer 1

1

You can't do this without a controller or a JavaScript function. The native StandardSetController does not automatically sort the records in any documented manner, nor can you customize the ordering with just a simple tag or attribute.

1
  • i'm just learning how to do apex - can you point me in the right direction on any resources that will help me create a custom controller to accomplish this? Jun 23, 2020 at 20:23

You must log in to answer this question.

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