salesforce 分页
2015-06-03 11:32
239 查看
自己 要做一个自定义开发的功能 然后 网上查了很多资料 自己整理了后 做了一个简单的salesforce 分页的功能
废话不都说 上代码
首先是 控制器 *__c 这些字段 可以自己创建 或者 代码里去掉
然后是apex页
废话不都说 上代码
首先是 控制器 *__c 这些字段 可以自己创建 或者 代码里去掉
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 , Profession__c , Email__c 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页
<apex:page standardController="Account" extensions="AccountListController"> <apex:form > <apex:pageBlock > <apex:pageMessages /> <apex:pageBlockSection columns="1"> <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.Profession__c}"/> </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.Email__c}" /> </apex:column> </apex:pageBlockTable> </apex:pageBlockSection> </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>
相关文章推荐
- more、less 和 most 的区别
- 十万条Access数据表分页的两个解决方法
- sqlserver关于分页存储过程的优化【让数据库按我们的意思执行查询计划】
- 高效的mysql分页方法及原理
- asp又一个分页的代码例子
- SqlServer 2000、2005分页存储过程整理第1/3页
- 透彻掌握ASP分页技术很详细的分析
- 一条SQL语句搞定Sql2000 分页
- 分页 SQLServer存储过程
- SQL行号排序和分页(SQL查询中插入行号 自定义分页的另类实现)
- mysql 分页优化解析
- 用ODBC的分页显示
- 一步步打造漂亮的新闻列表(无刷新分页、内容预览)第一步
- asp.net利用后台实现直接生成html分页的方法
- ASP万用分页程序
- asp下计算分页的几种方法
- Asp.net 通用万级数据分页代码[修正下载地址]
- jquery实现html页面 div 假分页有原理有代码
- 对之前写的jquery分页做下升级
- 基于Jquery+Ajax+Json实现分页显示附效果图