function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
yakup kaygusuzyakup kaygusuz 

Easiest way to sort tables

Is there any preset ways to sort tables based on column contents using visual force if not what would be the easiest and simplet way to sort tables
Gaurav NirwalGaurav Nirwal
{|class="wikitable sortable"
!Numbers!!Alphabet!!Dates!!Currency!!class="unsortable"|Unsortable
|-
|1||Z||02-02-2004||5.00||This
|-
|2||y||13-apr-2005||||Column
|-
|3||X||17.aug.2006||6.50||Is
|-
|4||w||01.Jan.2005||4.20||Unsortable
|-
|5||V||05/12/2006||7.15||See?
|-
!Total: 15!!!!!!Total: 29.55!!
|}
Gaurav NirwalGaurav Nirwal
If you can using the Java Script  and the code is that 

var date_from_string = function(str){
    var months = ["jan","feb","mar","apr","may","jun","jul",
    "aug","sep","oct","nov","dec"];
    var pattern = "^([a-zA-Z]{3})\\s*(\\d{2}),\\s*(\\d{4})$";
    var re = new RegExp(pattern);
    var DateParts = re.exec(str).slice(1);

    var Year = DateParts[2];
    var Month = $.inArray(DateParts[0].toLowerCase(), months);
    var Day = DateParts[1];
    return new Date(Year, Month, Day);
}

var table = $("#complexTable").stupidtable({
    "date":function(a,b){
        // Get these into date objects for comparison.
        aDate = date_from_string(a);
        bDate = date_from_string(b);

        return aDate - bDate;
    }
});


Gaurav NirwalGaurav Nirwal
Another method is that you can try this 

<table id="complexTable">
  <thead>
    <tr>
      <th data-sort="int" >int</th>
      <th data-sort="float">float</th>
      <th data-sort="string">string</th>
      <th>Can't sort me!</th>
      <th data-sort="date">date</th>
      <th data-sort="int">Letter frequency</th>
    </tr>
  </thead>
  ...
  ... (rest of the table)

If your problem can solves then select it best answer 
Grazitti TeamGrazitti Team
Hi,

You can do the table sorting with the help of jquery plugin.

Please see the link below:

http://tablesorter.com/docs/

Please mark as best answer if it solves your problem.

Regards,
Grazitti Team,
www.grazitti.com


yakup kaygusuzyakup kaygusuz
My table is built using visual force code here is the table code 

<apex:pageBlockTable value="{!lstcm}" var="cm">
                                 <apex:column headerValue="Call Result">
                    <apex:inputField value="{!cm.Call_Result__c}"  onchange="updateRecords();" />
               </apex:column>                         
                          <apex:column value="{!cm.contactId}"/>
                          <apex:column value="{!cm.Contact.Account.PersonMobilePhone}"/>
                          <apex:column value="{!cm.Contact.Account.PersonHomePhone}"/>
                          <apex:column value="{!cm.Contact.Account.PersonEmail}"/>
                          <apex:column value="{!cm.CampaignId}"/>
                          <apex:column value="{!cm.Status_Changed__c}"/>
                          <apex:column value="{!cm.Contact.Account.G1_Client_Relationship_Manager__c}"/>
                         
                  
 
                </apex:pageBlockTable>