java學(xué)習(xí)

          java學(xué)習(xí)

           

          extjs的分頁感悟

           

          Extjs中分頁的使用:

          在后臺(tái)查詢程序中查詢出的數(shù)據(jù)集合要放在一個(gè)輔助類的對(duì)象中輔助類要有2個(gè)屬性,一個(gè)放數(shù)據(jù)總數(shù),一個(gè)房數(shù)據(jù)集合,例如:

          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 + "}";

              }

           

          }

          把查詢出的額數(shù)據(jù)集合放在對(duì)象中

          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對(duì)象的totalRecords屬性一樣

                 idProperty : 'id',

                 fields : [ 'id', 'name', 'Unit', 'description' ],//集合中存放的對(duì)象的屬性

                 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 楊軍威 閱讀(501) 評(píng)論(0)  編輯  收藏


          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           

          導(dǎo)航

          統(tǒng)計(jì)

          常用鏈接

          留言簿

          隨筆檔案

          搜索

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          主站蜘蛛池模板: 徐州市| 黎平县| 台安县| 静安区| 泰顺县| 东港市| 墨竹工卡县| 锡林浩特市| 昌宁县| 阳信县| 连南| 洮南市| 武宁县| 德保县| 安宁市| 宁陕县| 镇康县| 娱乐| 洛南县| 荆门市| 旺苍县| 忻城县| 讷河市| 麟游县| 龙岩市| 手游| 大方县| 海宁市| 仪陇县| 延寿县| 闽清县| 游戏| 明水县| 潼关县| 西城区| 明光市| 广德县| 平江县| 顺平县| 德州市| 云南省|