+ Start a Discussion
Salesforce2015Salesforce2015 

VF PageBlock Table Sorting by Column

Hi Experts,

Below is my peace of VF Page Code (Pageblock Table).


<!-- table of data -->

<apex:pageBlockTable title="Time Sheets" value="{!tRecords}" var="c" id="pbt">
 <apex:column >
  <apex:facet name="header">
    <apex:facet name="header">
      <apex:inputCheckbox onclick="checkAll(this)"/>
    </apex:facet>
  </apex:facet>
  <apex:inputCheckbox value="{!c.isSelected}" rendered="{!!c.isCheckboxVisible}"/>
 </apex:column>

 <apex:column >
  <apex:facet Name="header">
    Time Card Number
  </apex:facet>
    <apex:outputLink value="/apex/ProjectWeekTimeCardNew?ptcid={!c.tTime.id}" target="_blank" >{!c.tTime.Name}</apex:outputLink>
 </apex:column>
 
 <apex:column >
   <apex:facet Name="header">
     Project Name
   </apex:facet>
     <apex:outputLink value="/{!c.tTime.Project_id__r.id}" target="_blank" >{!c.tTime.Project_id__r.Name}</apex:outputLink>
 </apex:column>                

 <apex:column value="{!c.tTime.Employee__c}"/>
 <apex:column value="{!c.tTime.Start_Date__c}"/>
 <apex:column value="{!c.tTime.End_Date__c}"/>
 <apex:column value="{!c.tTime.Total_Hours__c}"/>
 <apex:column value="{!c.tTime.Status__c}"/>
                
</apex:pageBlockTable>



Output:

User-added image


Requirement:

I need to show all green coloured checkboxes are first in table then all empty places (i.e No Checkboxes) are next.

Thanks,
Manu
 
bob_buzzardbob_buzzard
Take a look at my blog post on table sorting with JavaScript - you should be able to define the checkbox column as the default and then its just a matter of whether the checkboxes appear at the top for ascending or descending order:

http://bobbuzzard.blogspot.co.uk/2014/09/sorting-visualforce-tables-with.html