+ Start a Discussion
Kent ManningKent Manning 

What is the sort order on the dataTable tag?

I wrote the following Visualforce page to be used on our asset object.  It works as designed, but the records that are retruned are in a random order.  So two questions in reguard to this;

  • First, what determines the sort order of the dataTable tag?
  • Second, is there an attribute or command that I can use to specify which field is used to sort the data in the dataTable?

 

 

 <apex: page standardController="Company_Asset__c" standardStylesheets="true" standardStylesheets="true">

   <apex:dataTable value="{!Company_Asset__c.Loaner_Instruments__r}" var="LDI"  
         style="font-family:Arial,helvetica,sans-serif" style="font-size:11px" bgcolor="#F3F3fC" >
         

         <apex:column width="25"  rendered="{!Company_Asset__c.Loaner__c}" >
         </apex:column>
         <apex:column width="85"  rendered="{!Company_Asset__c.Loaner__c}" >{!LDI.Name} </apex:column>
         <apex:column width="60"  rendered="{!Company_Asset__c.Loaner__c}" style="color:red" >

                 <b>Status:</b> 

         </apex:column>
         <apex:column width="150" rendered="{!Company_Asset__c.Loaner__c}">
                   {!IF(Contains(LDI.Instrument_Status__c,"flag_red.gif" ), "Checked Out   "  ,"Checked In   " )}
         </apex:column>
         <apex:column width="150" rendered="{!Company_Asset__c.Loaner__c}" >

                  <b>Loaner Returned Date:</b>   

         </apex:column>
         <apex:column width="150" value="{!LDI.Loaner_Returned_Date__c}"

                     rendered="{!Company_Asset__c.Loaner__c}">
         </apex:column>
         <apex:column width="120" rendered="{!Company_Asset__c.Loaner__c}" style="color:green">

                    <b>Trade Show Ready:</b>
         </apex:column>
         <apex:column width="15" value="{!LDI.Inspected__c}" rendered="{!Company_Asset__c.Loaner__c}">
         </apex:column>
         <apex:column width="100"  rendered="{!Company_Asset__c.Loaner__c}">
         </apex:column>
    </apex:dataTable>
</apex: page>

 

Any help would be appreciated.

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Ron HessRon Hess
the data table does not sort it's value list.  to sort this, you would sort the list you bind to the data table component.

All Answers

Ron HessRon Hess
the data table does not sort it's value list.  to sort this, you would sort the list you bind to the data table component.
This was selected as the best answer
angusgrantangusgrant

Hi Ross,

 

What do you mean by "bind to the data table component". 

 

Do you mean that you would need to create an apex page which binds to the data table component with a custom SOQL query that orders the data as required?

 

I'm trying to create a page without writing any unnecessary apex and have come across this issue. 

 

Please clarify? 

 

Angus