I have a VF page displaying a pageblocktable, and I need to be able to sort the columns (most importantly the "name" column. Can anybody assist. Here are the relevant snippets of code from my VF page and Controller.
VF PAGE:
<apex:pageBlockTable value="{!wrapAccountList}" var="accWrap" id="table" title="All Accounts">
<apex:variable value="{!-1}" var="index" />
<apex:column >
<apex:facet name="header">
<apex:inputCheckbox onclick="selectAllCheckboxes(this,'inputId')"/>
</apex:facet>
<apex:inputCheckbox value="{!accWrap.selected}" id="inputId"/>
</apex:column>
<apex:column >
<apex:outputText >
<apex:variable value="{!index + 1}" var="index" />
{!index}
</apex:outputText>
</apex:column>
<apex:column headerValue="Name" value="{!accWrap.acc.contentdocumentid}" />
<apex:column headerValue="Owner" value="{!accWrap.acc.owner.name}" />
<apex:column headerValue="Last Modified" value="{!accWrap.acc.ContentModifiedDate}" />
<apex:column headerValue="Size" value="{!accWrap.acc.ContentSize}" />
</apex:pageBlockTable>
CONTROLLER:
public Id referralId { get; set; }
public Lead ref { get; set; }
public Id userId {get; set;}
public static boolean flag = true;
public string dateOfBirth {get; set;}
public string expensiveMeds {get; set;}
public List<ContentDocumentLink> listofattach {get; set;}
public List<wrapAccount> wrapAccountList {get; set;}
public List<contentversion> selectedAccounts{get;set;}
public List<ContentDocumentLink> attachmentsFullList {get; set;}
public boolean allSet {get;set;}
public boolean showFilesSection {get;set;}
public boolean authAlreadyRequested {get;set;}
public FileDeletionPageController(ApexPages.StandardController controller) {
ref = (Lead) controller.getRecord();
referralId = ref.Id;
userId = UserInfo.getUserId();
Lead ref = [select id,Name,Patient_DOB__c,Insurance_Company_formula__c,PayerPolicy__c, facility__r.name, Primary_Diagnosis__c,Referral_Account_formula__c
from lead where id = :ref.id];
dateOfBirth = string.valueof(ref.Patient_DOB__c);
string year = dateOfBirth.substring(0,4);
string month = dateOfBirth.substring(5,7);
string day = dateOfBirth.substring(8,10);
dateOfBirth = month + '/' + day + '/' + year;
listofattach = [SELECT Id, contentdocument.title,contentdocumentid FROM ContentDocumentLink where LinkedEntityId in (select id from lead where id = : referralId)];
set<id> contentdocumentids = new set<id>();
for (contentdocumentlink loa : listofattach){
contentdocumentids.add(loa.ContentDocumentId);
}
List <ContentVersion> contentVersions = new list<contentversion>();
contentVersions = [SELECT title,owner.name,ContentModifiedDate, ContentSize, Attach_to_auth_request__c, FileExtension,contentdocumentid FROM ContentVersion WHERE ContentDocumentId in :contentdocumentids and islatest !=false];
set<id> filteredContentDocumentIds = new set<id>();
for (contentVersion cont : contentVersions){
filteredContentDocumentIds.add(cont.contentdocumentid);
}
attachmentsFullList = [SELECT Id, contentdocument.title,contentdocumentid FROM ContentDocumentLink where LinkedEntityId in (select id from lead where id = : referralId) and ContentDocumentId in :filteredContentDocumentIds];
if (attachmentsFullList.size() > 0){
showFilesSection = true;
}
if(wrapAccountList == null) {
wrapAccountList = new List<wrapAccount>();
for(contentversion a: contentversions) {
wrapAccountList.add(new wrapAccount(a));
}
}
}
public class wrapAccount {
public contentversion acc {get; set;}
public Boolean selected {get; set;}
public wrapAccount(contentversion a) {
acc = a;
selected = false;
}
}