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


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           

          導航

          統計

          常用鏈接

          留言簿

          隨筆檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 枞阳县| 西青区| 玛沁县| 巢湖市| 安远县| 西乌| 桂阳县| 镇沅| 章丘市| 横山县| 和田县| 托克托县| 承德市| 桑植县| 化隆| 合肥市| 扬中市| 安吉县| 大城县| 临西县| 皋兰县| 琼中| 石泉县| 都匀市| 京山县| 兰溪市| 永寿县| 义马市| 兴城市| 邮箱| 新邵县| 启东市| 龙里县| 樟树市| 湟源县| 大兴区| 中阳县| 祁门县| 中牟县| 巫溪县| 屯门区|