Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <apex:page standardController="Account" recordSetVar="AccountsortList" action="{!ViewData}" extensions="AccountListViewController">
- <apex:sectionHeader title="My Accounts" subtitle="Account List View"/>
- <apex:form >
- <apex:pageBlock >
- <apex:pageMessages id="error" />
- <apex:pageBlockTable value="{!AccountsortList}" var="t" rendered="{!NOT(ISNULL(AccountsortList))}" id="blocktable">
- <apex:column >
- <apex:facet name="header">
- <apex:commandLink action="{!ViewData}" value="Account Name{!IF(ExpressionSort=='name',IF(DirectionOfSort == 'ASC', '▼', '▲'),'')}">
- <apex:param value="name" name="column" assignTo="{!ExpressionSort}" ></apex:param>
- </apex:commandLink>
- </apex:facet>
- <apex:outputLink value="/{!t.Id}" target="_blank">{!t.Name}</apex:outputLink>
- </apex:column>
- <!-- <apex:column headerValue="BillingState/Province" value="{!t.BillingState}"/>--->
- <apex:column value="{!t.BillingState}">
- <apex:facet name="header">
- <apex:commandLink action="{!ViewData}" value="BillingState{!IF(ExpressionSort=='BillingState',IF(DirectionOfSort == 'ASC', '▼', '▲'),'')}">
- <apex:param value="BillingState" name="column" assignTo="{!ExpressionSort}"></apex:param>
- </apex:commandLink>
- </apex:facet>
- </apex:column>
- <apex:column value="{!t.Phone}">
- <apex:facet name="header">
- <apex:commandLink action="{!ViewData}" value="Phone{!IF(ExpressionSort=='Phone',IF(DirectionOfSort == 'ASC', '▼', '▲'),'')}">
- <apex:param value="Phone" name="column" assignTo="{!ExpressionSort}"></apex:param>
- </apex:commandLink>
- </apex:facet>
- </apex:column>
- <apex:column value="{!t.Type}">
- <apex:facet name="header">
- <apex:commandLink action="{!ViewData}" value="Type{!IF(ExpressionSort=='Type',IF(DirectionOfSort == 'ASC', '▼', '▲'),'')}">
- <apex:param value="Type" name="column" assignTo="{!ExpressionSort}"></apex:param>
- </apex:commandLink>
- </apex:facet>
- </apex:column>
- <apex:column value="{!t.Owner.Name}">
- <apex:facet name="header">
- <apex:commandLink action="{!ViewData}" value="OwnerName{!IF(ExpressionSort=='Owner.Name',IF(DirectionOfSort == 'ASC', '▼', '▲'),'')}">
- <apex:param value="Owner.Name" name="column" assignTo="{!ExpressionSort}"></apex:param>
- </apex:commandLink>
- </apex:facet>
- </apex:column>
- <apex:column value="{!t.Website}">
- <apex:facet name="header">
- <apex:commandLink action="{!ViewData}" value="Website{!IF(ExpressionSort=='website',IF(DirectionOfSort == 'ASC', '▼', '▲'),'')}">
- <apex:param value="Website" name="column" assignTo="{!ExpressionSort}"></apex:param>
- </apex:commandLink>
- </apex:facet>
- </apex:column>
- <!-- <apex:column headerValue="Account Owner Alias" value="{!t.Owner.Name}"/>--->
- <!-- <apex:column headerValue="Website" value="{!t.Website}"/>---->
- <apex:inlineEditSupport event="onClick"/>
- </apex:pageBlockTable>
- <apex:panelGrid columns="7" id="buttons" >
- <!---<apex:pageBlockButtons>---->
- <apex:commandButton reRender="error,blocktable,buttons" action="{!Save}" value="Save"/>
- <apex:commandButton reRender="error,blocktable,buttons" action="{!Cancel}" value="Cancel"/>
- <apex:inputHidden />
- <apex:commandButton reRender="error,blocktable,buttons" disabled="{!!hasprevious}" action="{!First}" value="First"/>
- <apex:commandButton reRender="error,blocktable,buttons" disabled="{!!hasprevious}" action="{!Previous}" value="Previous"/>
- <apex:commandButton reRender="error,blocktable,buttons" disabled="{!!hasnext}" action="{!Next}" value="Next"/>
- <apex:commandButton reRender="error,blocktable,buttons" disabled="{!!hasnext}" action="{!Last}" value="Last"/>
- <!---</apex:pageBlockButtons>--->
- </apex:panelGrid>
- </apex:pageBlock>
- </apex:form>
- </apex:page>
- public class AccountListViewController{
- public List<Account> AccountsortList {get; set;}
- public String SortingExpression = 'name';
- public String DirectionOfSort = 'ASC';
- public Integer NoOfRecords {get; set;}
- public Integer Size{get; set;}
- public AccountListViewController(ApexPages.StandardSetController controller) {
- AccountsortList = new List<Account>();
- ApexPages.StandardSetController ssc = new ApexPages.StandardSetController(AccountsortList);
- }
- /*public Integer pageNumber {
- get {
- return ssc.getpageNumber();
- }
- set;
- }*/
- public String ExpressionSort {
- get {
- return SortingExpression;
- }
- set {
- If(value == SortingExpression) {
- DirectionOfSort = (DirectionOfSort == 'ASC')? 'DESC' : 'ASC';
- }
- else {
- DirectionOfSort = 'ASC';
- SortingExpression = value;
- }
- }
- }
- public String getDirectionOfSort() {
- If(SortingExpression == Null || SortingExpression == '') {
- return 'DESC';
- }
- else {
- return DirectionOfSort;
- }
- }
- public void setDirectionOfSort(String value) {
- DirectionOfSort = value;
- }
- public List<Account>getAccounts() {
- return AccountsortList;
- }
- public PageReference ViewData() {
- String FullSortExpression = SortingExpression + ' ' + DirectionOfSort;
- system.debug('SortingExpression:::::'+SortingExpression);
- system.debug(DirectionOfSort);
- String Queryitem = ' SELECT Id, Name, Phone, BillingState, Type, Owner.Name, Website FROM Account WHERE Account.Name != Null ORDER BY ' + FullSortExpression +' Limit 10';
- system.debug(Queryitem);
- AccountsortList = DataBase.query(Queryitem);
- system.debug(AccountsortList);
- return Null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement