65、salesforce的数据分页
<apex:page controller="PagingController">
<apex:form >
<apex:pageBlock title="Invoices"> <apex:pageBlockButtons location="top">
<apex:commandButton action="{!process}" value="Selected" />
<apex:commandButton action="{!cancel}" value="Cancel" />
</apex:pageBlockButtons>
<apex:pageMessages /> <apex:pageBlockSection title="Goods - Page {!pageNumber}" columns="1">
<apex:pageBlockTable value="{!categories}" var="c">
<apex:column width="25px">
<apex:inputCheckbox value="{!c.checked}" />
</apex:column>
<apex:column value="{!c.invoice.Name}" headerValue="Name" />
<apex:column value="{!c.invoice.Invoice_Total1__c}" headerValue="Total" />
<apex:column value="{!c.invoice.Status__c}" headerValue="Status" />
</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>
Controller的代码
public with sharing class PagingController {
List<categoryWrapper> categories {get;set;}
//instantiate the StandardSetController from a query locator
public ApexPages.StandardSetController con{
get{
if(con==null){
con = new ApexPages.StandardSetController(Database.getQueryLocator([SELECT Name,Invoice_Total1__c,Status__c,Id from Invoice__c]));
con.setPageSize(4);
}
return con;
}
set;
}
//returns a list of wrapper objects for the sObjects in the current page set
public List<categoryWrapper> getCategories(){
categories = new List<categoryWrapper>();
for(Invoice__c invoice : (List<Invoice__c>)con.getRecords()){
categories.add(new CategoryWrapper(invoice));
}
return categories;
}
//displays the selected items
public PageReference process(){
for(CategoryWrapper cw:categories){
if(cw.checked){
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,cw.invoice.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();
}
}
包装类的代码
public class CategoryWrapper {
public Boolean checked{get;set;}
public Invoice__c invoice{get;set;}
public CategoryWrapper(){
invoice = new Invoice__c();
checked = false;
}
public CategoryWrapper(Invoice__c invoice){
this.invoice = invoice;
checked = false;
}
}
最后实现的效果如下图所示

65、salesforce的数据分页的更多相关文章
- salesforce 零基础开发入门学习(八)数据分页简单制作
本篇介绍通过使用VF自带标签和Apex实现简单的数据翻页功能. 代码上来之前首先简单介绍一下本篇用到的主要知识: 1.ApexPages命名空间 此命名空间下的类用于VF的控制. 主要的类包括但不限于 ...
- mysq大数据分页
mysql limit大数据量分页优化方法 Mysql的优化是非常重要的.其他最常用也最需要优化的就是limit.Mysql的limit给分页带来了极大的方便,但数据量一大的时候,limit的性能就急 ...
- Sql Server 数据分页
http://www.cnblogs.com/qqlin/archive/2012/11/01/2745161.html 1.引言 在列表查询时由于数据量非常多,一次性查出来会非常慢,就算一次查出来了 ...
- Oracle、MySql、SQLServer数据分页查询
看过此博文后Oracle.MySql.SQLServer 数据分页查询,在根据公司的RegionRes表格做出了 SQLserver的分页查询语句: 别名.字段 FROM( SELECT row_nu ...
- 知方可补不足~SQL2005使用ROW_NUMBER() OVER()进行数据分页
回到目录 数据分页是这个经常说的东西,无论在WEBForm还是WinForm中它都会被单独拿出来,或者是公用组件,或者是公用类库,反正对于数据分页这个东西,总是我们关注的一个话题,但事实上,数据分页归 ...
- Oracle中的数据分页
--数据分页脚本 --创建包含数据分页代码元素声明的包头结构create or replace package data_controlis type type_cursor_data is ref ...
- 数据分页处理系列之三:Neo4j图数据分页处理
首先简单介绍下Neo4j,Neo4j是一个高性能的NOSQL图形数据库,它将结构化数据存储在网络上而不是表中,它是一个嵌入式的.基于磁盘的.具备完全的事务特性的Java持久化引擎,但是它将结构化数 ...
- 数据分页处理系列之二:HBase表数据分页处理
HBase是Hadoop大数据生态技术圈中的一项关键技术,是一种用于分布式存储大数据的列式数据库,关于HBase更加详细的介绍和技术细节,朋友们可以在网络上进行搜寻,笔者本人在接下来的日子里也会写 ...
- 数据分页处理系列之一:Oracle表数据分页检索SQL
关于Oracle数据分页检索SQL语法,网络上比比皆是,花样繁多,本篇也是笔者本人在网络上搜寻的比较有代表性的语法,绝非本人原创,贴在这里,纯粹是为了让"数据分页专题系列"看起 ...
随机推荐
- php关键字static使用
php中static关键字使用: 情景1:静态变量 使用static关键字定义静态变量 静态变量:只存在于函数作用域内,也就是说,静态变量只存活在栈中.一般的函数内变量在函数结束后会释放,比如局部变量 ...
- 嵌入式开发环境搭建(一) 虚拟机实现桥接Ethernet网口 并且通过WIFI进行NAT联网
背景: 目前手头上有一块JZ2440的板子,之前有搭建完整套开发环境,由于虚拟机故障需要从新搭建服务器端,故在此记录搭建步骤 环境: Ubuntu16.4 VMWare 12 先行条件: 先按照自定义 ...
- java并发编程笔记(八)——死锁
java并发编程笔记(八)--死锁 死锁发生的必要条件 互斥条件 进程对分配到的资源进行排他性的使用,即在一段时间内只能由一个进程使用,如果有其他进程在请求,只能等待. 请求和保持条件 进程已经保持了 ...
- 抽象类 抽象方法 abstract
abstract: * abstract修饰类: 抽象类 * > 此类不能被实例化 * > 抽象类中一定要有构造器, 便于子类对象实例时调用(涉及子类对象实例化过程) * > 开发中 ...
- vue搭建项目之设置axios
首先要下载axios: npm install axios -S 要注意的是,axios不支持Vue.use();这种方式,可以改写原型链. 第二步就是新建axios存放位置: 在项目中src中单独建 ...
- vector的自定义实现
#pragma warning(disable:4996) #include<iostream> #include<string> #include<vector> ...
- LeetCode刷题: 【120】三角形最小路径和
1. 题目: 给定一个三角形,找出自顶向下的最小路径和.每一步只能移动到下一行中相邻的结点上. 例如,给定三角形: [ [2], [3,4], [6,5,7], [4,1,8,3] ] 自顶向下的最小 ...
- Redis 系列
Redis 系列 [Redis 系列(01)安装配制] [Redis 系列(02)数据结构] [Redis 系列(03-1)进阶 - 发布订阅] [Redis 系列(03-2)进阶 - 事务] [Re ...
- C++中的多重继承(二)
1,本文分析另一个多重继承问题及其工程中的解决方案,单继承加多接口实现的开发方式: 2,多重继承的问题三: 1,多重继承可能产生多个虚函数表: 1,实际工程中可能造成不可思议的问题,并且这些问题很难以 ...
- redis缓存架构-02-两种持久化机制(RDB和AOF)
1.两种持久化机制的介绍 1.1 RDB 周期性的生成redis内存数据的一份完整的快照 1)根据配置的检查点,生产rdb快照文件,fork一个子线程,将数据dump到rdb快照文件中,完成rdb文件 ...