salesforce使用Apex控制器和VF实现自定义服务器端分页项目实战(自定义分页)
2017-03-29 12:18
459 查看
此篇博文将完整地介绍如何自定义数据列表分页,学习本节后你将学到如下知识:
1、如何扩展原有的标准控制器,让自定义扩展器发挥更个性的功能,在vf中增加extensions属性实现自定义控制器的关联;
2、如何利用表达式编辑或删除记录,以及如何利用表达式进行逻辑判断;
下面是code部分:
效果预览:
1、如何扩展原有的标准控制器,让自定义扩展器发挥更个性的功能,在vf中增加extensions属性实现自定义控制器的关联;
2、如何利用表达式编辑或删除记录,以及如何利用表达式进行逻辑判断;
下面是code部分:
public class AccountListController { List<Account> account{get;set;} public AccountListController (ApexPages.StandardController controller) { } // instantiate the StandardSetController from a query locator public ApexPages.StandardSetController con { get { if(con == null) { con = new ApexPages.StandardSetController(Database.getQueryLocator( [SELECT Id, Name , Type , Phone, Owner.Name, Industry FROM Account Order By Name limit 100])); // sets the number of records in each page set con.setPageSize(15); } return con; } set; } // returns a list of wrapper objects for the sObjects in the current page set public List<Account> getAccounts() { return (List<Account>) con.getRecords(); } // displays the selected items public PageReference process() { // for (CategoryWrapper cw : categories) { // if (cw.checked) // ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,cw.cat.name)); // } return null; } // indicates whether there are more records after the current page set. public Boolean hasNext { get { return con.getHasNext(); } set; } // indicates whether there are more records before the current page set. public Boolean hasPrevious { get { return con.getHasPrevious(); } set; } // returns the page number of the current page set public Integer pageNumber { get { return con.getPageNumber(); } set; } // returns the first page of records public void first() { con.first(); } // returns the last page of records public void last() { con.last(); } // returns the previous page of records public void previous() { con.previous(); } // returns the next page of records public void next() { con.next(); } // returns the PageReference of the original page, if known, or the home page. public void cancel() { con.cancel(); } }
<apex:page standardController="Account" extensions="AccountListController"> <apex:form > <apex:pageBlock title="Account List"> <apex:pageBlockTable value="{!Accounts}" var="a"> <apex:column headerValue="操作" style="width:5%"> <a href="{!URLFOR($Action.Account.Edit,a.id,[retURL=''])}">编辑</a>丨 <a href="{!URLFOR($Action.Account.Delete,a.id,[retURL=''])}">删除</a> </apex:column> <apex:column headerValue="名称" style="width:15%"> <apex:outputLink value="{!URLFOR($Action.Account.View,a.id,[retURL=''])}">{!a.Name}</apex:outputLink> </apex:column> <apex:column headerValue="行业" style="width:15%"> <apex:outputField value="{!a.Industry}"/> </apex:column> <apex:column headerValue="电话" style="width:15%"> <a href="#" onclick="singheadDial('6112',{!a.Phone});" id="dial2"> <apex:outputPanel rendered="{!IF(a.Phone != '',true,false)}"> {!a.Phone} <!-- <apex:image url="{!URLFOR($Resource.phone1, 'phone1.jpg')}" height="15px" width="15px"/> --> </apex:outputPanel> </a> </apex:column> <apex:column headerValue="类型" style="width:15%"> <apex:outputField value="{!a.Type}" /> </apex:column> </apex:pageBlockTable> </apex:pageBlock> <apex:panelGrid columns="4"> <apex:commandLink action="{!first}">First</apex:commandlink> <apex:commandLink action="{!previous}" rendered="{!hasPrevious}">Previous</apex:commandlink> <apex:commandLink action="{!next}" rendered="{!hasNext}">Next</apex:commandlink> <apex:commandLink action="{!last}">Last</apex:commandlink> </apex:panelGrid> </apex:form> </apex:page>
效果预览:
相关文章推荐
- salesforce 零基础学习(二十六)自定义图表chart简单介绍(使用apex和VF实现)
- salesforce 零基础学习(四十九)自定义列表分页之使用Pagination实现分页效果 ※※※
- ASP.NET 使用DataTable在Table中实现自定义分页
- 使用Silverlight3中的DataPager实现服务器端分页
- salesforce apex + vf page 实现JSON
- 项目实战之服务端分页的实现——SQL
- 使用ASP.NET Web Api构建基于REST风格的服务实战系列教程【七】——实现资源的分页
- 在ASP.NET AJAX中使用应用程序服务和本地化(5):自定义应用程序服务的服务器端实现
- 猫猫学iOS 之微博项目实战(2)微博主框架-自定义导航控制器NavigationController
- Salesforce apex + vf page 服务器端分页 II
- 项目实战TT(三) .NET4中托盘的实现和皮肤的使用
- GridView实战二:使用ObjectDataSource数据源控件(自定义缓存机制实现Sort)
- NHibernate+WCF项目实战(二)使用NHibernate实现数据访问并进行单元测试
- 利用 Salesforce的apex:outputText 实现VF画面的格式化
- ASP.NET 使用DataTable在Table中实现自定义分页
- 使用Gridview和ObjectDataSource轻松实现自定义分页
- 使用Silverlight3中的DataPager实现服务器端分页
- 使用Silverlight3中的DataPager实现服务器端分页[转]
- Android开发实战2----圆点导航指示器(使用自定义View实现)
- 使用mssql2008新特性(存储过程参数类型使用"用户自定义表"来实现批量DML更新多表)解决项目里遇到的性能问题