Apex Class -
Visualforce Page -
Reference -
http://salesforcesource.blogspot.com/2008/11/adding-sorting-capability-to.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class OpportunityProductsExt { | |
private List<OpportunityLineItem> products; | |
private String sortDirection = 'ASC'; | |
private String sortExp = 'name'; | |
Id oppId; | |
public OpportunityProductsExt(ApexPages.standardController stdCon) { | |
oppId = stdCon.getId(); | |
ViewData(); | |
} | |
public String sortExpression | |
{ | |
get { | |
return sortExp; | |
} | |
set { | |
//if the column is clicked on then switch between Ascending and Descending modes | |
if (value == sortExp) | |
sortDirection = (sortDirection == 'ASC')? 'DESC' : 'ASC'; | |
else | |
sortDirection = 'ASC'; | |
sortExp = value; | |
} | |
} | |
public String getSortDirection() { | |
//if not column is selected | |
if (sortExpression == null || sortExpression == '') | |
return 'ASC'; | |
else | |
return sortDirection; | |
} | |
public void setSortDirection(String value) { | |
sortDirection = value; | |
} | |
public List<OpportunityLineItem> getProducts() { | |
return products; | |
} | |
public PageReference ViewData() { | |
//build the full sort expression | |
string sortFullExp = sortExpression + ' ' + sortDirection; | |
//query the database based on the sort expression | |
products = Database.query('Select id, Product2.Name, Quantity, ServiceDate, UnitPrice, Discount, Subtotal, TotalPrice from OpportunityLineItem where OpportunityId ='+'\''+oppId+'\''+' order by ' + sortFullExp + ' limit 1000'); | |
return null; | |
} | |
} |
Visualforce Page -
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<apex:page standardController="Opportunity" extensions="OpportunityProductsExt"> | |
<apex:form > | |
<apex:pageblock title="Products"> | |
<apex:pageblockButtons location="top"> | |
<apex:commandButton value="Edit All" onclick="window.open('/oppitm/multilineitem.jsp?oppId={!Opportunity.id}&retURL=/{!Opportunity.id}','_parent')"/> | |
<apex:commandButton value="Choose Price Book" onclick="window.open('/oppitm/choosepricebook.jsp?id={!Opportunity.id}&retURL=/{!Opportunity.id}&saveURL=/{!Opportunity.id}','_parent')"/> | |
<apex:commandButton value="Sort" onclick="window.open('/oppitm/lineitemsort.jsp?id={!Opportunity.id}&retURL=/{!Opportunity.id}','_parent')"/> | |
</apex:pageblockButtons> | |
<apex:pageblockTable value="{!products}" var="prod"> | |
<apex:column> | |
<apex:facet name="header"> | |
<apex:outputPanel> | |
<apex:inputCheckbox/> | |
<apex:outputLabel value="Action"/> | |
</apex:outputPanel> | |
</apex:facet> | |
<apex:inputCheckbox/> | |
<apex:outputText value=" | "/> | |
<apex:commandLink value="Edit" action="/{!prod.id}/e?retURL=/{!Opportunity.id}" target="_parent"/> | |
<apex:outputText value=" | "/> | |
<apex:commandLink value="Del" onclick="return confirm('Are you sure?');" action="{!URLFOR($Action.OpportunityLineItem.delete,prod.id)}"/> | |
</apex:column> | |
<apex:column headerValue="Product"> | |
<apex:outputLink value="/{!prod.Id}">{!prod.Product2.Name}</apex:outputLink> | |
</apex:column> | |
<apex:column> | |
<apex:facet name="header"> | |
<apex:commandLink action="{!ViewData}" value="Product Family{!IF(sortExpression=='Quantity',IF(sortDirection='ASC','▼','▲'),'')}" id="cmdSort"> | |
<apex:param value="Quantity" name="column" assignTo="{!sortExpression}" ></apex:param> | |
</apex:commandLink> | |
</apex:facet> | |
{!prod.Quantity} | |
</apex:column> | |
<apex:column value="{!prod.ServiceDate}"/> | |
<apex:column value="{!prod.UnitPrice}"/> | |
<apex:column value="{!prod.Discount}"/> | |
<apex:column value="{!prod.Subtotal}"/> | |
<apex:column value="{!prod.TotalPrice}"/> | |
</apex:pageblockTable> | |
</apex:pageblock> | |
</apex:form> | |
</apex:page> |
http://salesforcesource.blogspot.com/2008/11/adding-sorting-capability-to.html
Nice blog.
ReplyDeletepython training in bangalore
python training in pune
python training in mumbai
Nice blog
ReplyDeleteaws training in bangalore
artificial intelligence training in bangalore
machine learning training in bangalore
blockchain training in bangalore
iot training in bangalore
artificial intelligence certification
artificial intelligence certification
Zaman sekarang banyak sekali jenis hiburan yang dicari orang kebanyakan orang adalah hiburan melalui online, situs bandar judi domino online kelebihan yang harus anda ketahui pun hadir sebagai salah satu game atau hiburan yang mudah dan melengkapi kesenangan para pemainnya.
ReplyDeleteasikqq
http://dewaqqq.club/
http://sumoqq.today/
interqq
pionpoker
bandar ceme terpercaya
freebet tanpa deposit
paito warna
syair sgp
Very interesting information and this is very useful in my future. Please update them.
ReplyDeleteExcel Training in Chennai
Excel classes in Chennai
Tableau Training in Chennai
Oracle Training in Chennai
Linux Training in Chennai
Spark Training in Chennai
Embedded System Course Chennai
Oracle DBA Training in Chennai
Excel Training in Vadapalani
Excel Training in Thiruvanmiyur
I got some clear information from this blog.. Thanks for taking a time to share this blog...
ReplyDeleteAWS Training in Chennai
AWS Training in Bangalore
Best AWS Training in Bangalore
AWS Training Institutes in Bangalore
AWS Certification Training in Bangalore
Data Science Courses in Bangalore
DevOps Training in Bangalore
DOT NET Training in Bangalore
AWS Training in BTM
Best AWS Training in Marathahalli
Great Blog!!! Thanks for sharing this wonderful post with us.
ReplyDeletePython Training in Chennai
Python course in Chennai
Python Training Institute in Chennai
Best Python Training in Chennai
Python training in porur
Python training in OMR
Big data training in chennai
Android Training in Chennai
IOS Training in Chennai
Selenium Training in Chennai
This comment has been removed by the author.
ReplyDeleteGood blog, it's really very informative, do more blogs under good concepts.
ReplyDeletewhat is use of python
ccna career opportunities
is python good for web development
skills required for machine learning
data science questions and answers pdf
Mua vé máy bay tại Aivivu, tham khảo
ReplyDeletevé máy bay đi Mỹ
giá vé máy bay từ mỹ về việt nam
lich bay tu duc ve viet nam
vé máy bay từ việt nam sang nga bao nhiêu
các chuyến bay từ anh về việt nam
chuyến bay từ pháp về việt nam hôm nay
Mmorpg oyunları
ReplyDeleteinstagram takipçi satın al
Tiktok Jeton Hilesi
referans kimliği nedir
instagram takipçi satın al
metin2 pvp serverlar
İnstagram takipci satın al