java学习

java学习

 

extjs的分页感悟

 

Extjs中分页的使用:

在后台查询程序中查询出的数据集合要放在一个辅助类的对象中辅助类要有2个属性,一个放数据总数,一个房数据集合,例如:

public class DirectStore {

 

    private int totalRecords;

    private final List<?> results;

 

    public DirectStore(final int totalRecord, final List<?> results) {

       super();

       this.totalRecords = totalRecord;

       this.results = results;

    }

 

    public List<?> getResults() {

       return this.results;

    }

 

    public int getTotalRecord() {

       return this.totalRecords;

    }

 

    public void setTotalRecord(final int totalRecord) {

       this.totalRecords = totalRecord;

    }

 

    @Override

    public String toString() {

       return "{'totalRecords':" + this.totalRecords + ",'results'"

              + this.results + "}";

    }

 

}

把查询出的额数据集合放在对象中

DirectStore store = new DirectStore(recordNumber, list);

ext的页面中,需要先定义如下:

var typeStore = new Ext.data.DirectStore({

       paramOrder : [ 'start', 'limit' ],

       baseParams : {

           'start' : 0,

           'limit' : 20

       },

       root : 'results',

       totalProperty : 'totalRecords',//DirectStore对象的totalRecords属性一样

       idProperty : 'id',

       fields : [ 'id', 'name', 'Unit', 'description' ],//集合中存放的对象的属性

       directFn : EamDjn.getDepartment

    });

    typeStore.load();

再在页面下面写:

bbar: new Ext.PagingToolbar({

           pageSize: 20,

           store : typeStore,

           displayInfo: true,

           displayMsg: '显示第 {0} 条到 {1} 条记录,一共 {2} ',

           emptyMsg: '没有记录'

       })

这样就完成分页了,需要

posted on 2012-11-08 16:17 杨军威 阅读(483) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航:
 

导航

统计

常用链接

留言簿

随笔档案

搜索

最新评论

阅读排行榜

评论排行榜