Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.91 KB | None | 0 0
  1. <apex:page standardController="Account" recordSetVar="AccountsortList" action="{!ViewData}" extensions="AccountListViewController">
  2.  
  3. <apex:sectionHeader title="My Accounts" subtitle="Account List View"/>
  4. <apex:form >
  5. <apex:pageBlock >
  6. <apex:pageMessages id="error" />
  7.  
  8. <apex:pageBlockTable value="{!AccountsortList}" var="t" rendered="{!NOT(ISNULL(AccountsortList))}" id="blocktable">
  9.  
  10. <apex:column >
  11. <apex:facet name="header">
  12. <apex:commandLink action="{!ViewData}" value="Account Name{!IF(ExpressionSort=='name',IF(DirectionOfSort == 'ASC', '▼', '▲'),'')}">
  13. <apex:param value="name" name="column" assignTo="{!ExpressionSort}" ></apex:param>
  14. </apex:commandLink>
  15. </apex:facet>
  16. <apex:outputLink value="/{!t.Id}" target="_blank">{!t.Name}</apex:outputLink>
  17. </apex:column>
  18.  
  19.  
  20. <!-- <apex:column headerValue="BillingState/Province" value="{!t.BillingState}"/>--->
  21. <apex:column value="{!t.BillingState}">
  22. <apex:facet name="header">
  23. <apex:commandLink action="{!ViewData}" value="BillingState{!IF(ExpressionSort=='BillingState',IF(DirectionOfSort == 'ASC', '▼', '▲'),'')}">
  24. <apex:param value="BillingState" name="column" assignTo="{!ExpressionSort}"></apex:param>
  25. </apex:commandLink>
  26. </apex:facet>
  27. </apex:column>
  28.  
  29. <apex:column value="{!t.Phone}">
  30. <apex:facet name="header">
  31. <apex:commandLink action="{!ViewData}" value="Phone{!IF(ExpressionSort=='Phone',IF(DirectionOfSort == 'ASC', '▼', '▲'),'')}">
  32. <apex:param value="Phone" name="column" assignTo="{!ExpressionSort}"></apex:param>
  33. </apex:commandLink>
  34. </apex:facet>
  35. </apex:column>
  36.  
  37. <apex:column value="{!t.Type}">
  38. <apex:facet name="header">
  39. <apex:commandLink action="{!ViewData}" value="Type{!IF(ExpressionSort=='Type',IF(DirectionOfSort == 'ASC', '▼', '▲'),'')}">
  40. <apex:param value="Type" name="column" assignTo="{!ExpressionSort}"></apex:param>
  41. </apex:commandLink>
  42. </apex:facet>
  43. </apex:column>
  44.  
  45. <apex:column value="{!t.Owner.Name}">
  46. <apex:facet name="header">
  47. <apex:commandLink action="{!ViewData}" value="OwnerName{!IF(ExpressionSort=='Owner.Name',IF(DirectionOfSort == 'ASC', '▼', '▲'),'')}">
  48. <apex:param value="Owner.Name" name="column" assignTo="{!ExpressionSort}"></apex:param>
  49. </apex:commandLink>
  50. </apex:facet>
  51. </apex:column>
  52.  
  53. <apex:column value="{!t.Website}">
  54. <apex:facet name="header">
  55. <apex:commandLink action="{!ViewData}" value="Website{!IF(ExpressionSort=='website',IF(DirectionOfSort == 'ASC', '▼', '▲'),'')}">
  56. <apex:param value="Website" name="column" assignTo="{!ExpressionSort}"></apex:param>
  57. </apex:commandLink>
  58. </apex:facet>
  59. </apex:column>
  60.  
  61. <!-- <apex:column headerValue="Account Owner Alias" value="{!t.Owner.Name}"/>--->
  62. <!-- <apex:column headerValue="Website" value="{!t.Website}"/>---->
  63.  
  64. <apex:inlineEditSupport event="onClick"/>
  65.  
  66.  
  67. </apex:pageBlockTable>
  68.  
  69. <apex:panelGrid columns="7" id="buttons" >
  70. <!---<apex:pageBlockButtons>---->
  71. <apex:commandButton reRender="error,blocktable,buttons" action="{!Save}" value="Save"/>
  72. <apex:commandButton reRender="error,blocktable,buttons" action="{!Cancel}" value="Cancel"/>
  73. <apex:inputHidden />
  74.  
  75. <apex:commandButton reRender="error,blocktable,buttons" disabled="{!!hasprevious}" action="{!First}" value="First"/>
  76. <apex:commandButton reRender="error,blocktable,buttons" disabled="{!!hasprevious}" action="{!Previous}" value="Previous"/>
  77. <apex:commandButton reRender="error,blocktable,buttons" disabled="{!!hasnext}" action="{!Next}" value="Next"/>
  78. <apex:commandButton reRender="error,blocktable,buttons" disabled="{!!hasnext}" action="{!Last}" value="Last"/>
  79. <!---</apex:pageBlockButtons>--->
  80. </apex:panelGrid>
  81.  
  82.  
  83. </apex:pageBlock>
  84. </apex:form>
  85. </apex:page>
  86.  
  87. public class AccountListViewController{
  88. public List<Account> AccountsortList {get; set;}
  89. public String SortingExpression = 'name';
  90. public String DirectionOfSort = 'ASC';
  91. public Integer NoOfRecords {get; set;}
  92. public Integer Size{get; set;}
  93.  
  94. public AccountListViewController(ApexPages.StandardSetController controller) {
  95. AccountsortList = new List<Account>();
  96. ApexPages.StandardSetController ssc = new ApexPages.StandardSetController(AccountsortList);
  97.  
  98. }
  99.  
  100. /*public Integer pageNumber {
  101. get {
  102. return ssc.getpageNumber();
  103. }
  104. set;
  105. }*/
  106. public String ExpressionSort {
  107. get {
  108. return SortingExpression;
  109. }
  110. set {
  111. If(value == SortingExpression) {
  112. DirectionOfSort = (DirectionOfSort == 'ASC')? 'DESC' : 'ASC';
  113. }
  114. else {
  115. DirectionOfSort = 'ASC';
  116. SortingExpression = value;
  117. }
  118. }
  119.  
  120. }
  121.  
  122. public String getDirectionOfSort() {
  123. If(SortingExpression == Null || SortingExpression == '') {
  124. return 'DESC';
  125. }
  126. else {
  127. return DirectionOfSort;
  128. }
  129. }
  130.  
  131. public void setDirectionOfSort(String value) {
  132. DirectionOfSort = value;
  133. }
  134.  
  135. public List<Account>getAccounts() {
  136. return AccountsortList;
  137. }
  138.  
  139. public PageReference ViewData() {
  140. String FullSortExpression = SortingExpression + ' ' + DirectionOfSort;
  141. system.debug('SortingExpression:::::'+SortingExpression);
  142. system.debug(DirectionOfSort);
  143.  
  144. String Queryitem = ' SELECT Id, Name, Phone, BillingState, Type, Owner.Name, Website FROM Account WHERE Account.Name != Null ORDER BY ' + FullSortExpression +' Limit 10';
  145. system.debug(Queryitem);
  146.  
  147. AccountsortList = DataBase.query(Queryitem);
  148. system.debug(AccountsortList);
  149. return Null;
  150. }
  151. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement