You need to sign in to do that
Don't have an account?
Object List Query - How to add sorting Arrows
Hi There,
I have an Account Query Controller, I was wondering if I could get a hand on how to add sorting. This is a subject that has always confused me, I figure if I can deploy and understand (to a point) a controller like this, I should be able to implement acollumn sorting function. Any help or a point in the right direction would be much appreciated.
This is my current controlle query
I have an Account Query Controller, I was wondering if I could get a hand on how to add sorting. This is a subject that has always confused me, I figure if I can deploy and understand (to a point) a controller like this, I should be able to implement acollumn sorting function. Any help or a point in the right direction would be much appreciated.
This is my current controlle query
public with sharing class Account_Query { Public String baseQuery = 'select ID, Name, Office__c, Account_active__c, Account_Status__c, Support_expiration__c FROM Account ORDER BY NAME ASC'; public String AccFilterId {get; set;} Public Integer pageSize = 750; Public Integer pageNumber = 1; Public Integer totalPageNumber = 0; public Account_Query (){} public ApexPages.StandardSetController AccSetController { get{ if(AccSetController == null){ AccSetController = new ApexPages.StandardSetController(Database.getQueryLocator(baseQuery)); // We have to set FilterId after Pagesize, else it will not work AccSetController.setPageSize(pageSize); if(AccFilterId != null) { AccSetController.setFilterId(AccFilterId); } } return AccSetController; }set; } public Account_Query (ApexPages.StandardSetController c) { } //Page Number - added by be public Integer getPageNumber() { return AccSetController.getPageNumber(); } //Navigate to first Page public void firstPage() { AccSetController.first(); } //Navigate to last Page public void lastPage() { AccSetController.last(); } //Navigate to Next page public void next() { if(AccSetController.getHasNext()) { AccSetController.next(); } } //Navigate to Prev Page public void prev() { if(AccSetController.getHasPrevious()) { AccSetController.previous(); } } public List<Account> getAccounts() { return (List<Account>)AccSetController.getRecords(); } //Get all available list view for Account public SelectOption[] getAccountExistingViews(){ return AccSetController.getListViewOptions(); } //Page Number total - public Integer getTotalPageNumber() { if (totalPageNumber == 0 && AccSetController.getResultSize() !=null) { totalPageNumber = AccSetController.getResultSize() / pageSize; Integer mod = AccSetController.getResultSize() - (totalPageNumber * pageSize); if (mod > 0) totalPageNumber++; } return totalPageNumber; } //Prev Enabled - public Boolean getPreviousButtonEnabled() { return !(AccSetController.getPageNumber() > 1); } //Next Disabled public Boolean getNextButtonDisabled() { return ((AccSetController.getPageNumber() * AccSetController.getPageSize()) >= AccSetController.getResultSize()); } /** * Reset List View */ public PageReference resetFilter() { AccSetController = null; AccSetController.setPageNumber(1); totalPageNumber = 0; pageSize = 750; return null; } }