夢幻之旅

          DEBUG - 天道酬勤

             :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            671 隨筆 :: 6 文章 :: 256 評論 :: 0 Trackbacks
          今晚,說不出的高興,折磨了我好久的Grid終于可以按搜索條件分頁了,激動啊....
          function listStudent() {
              
          function renderSex(value) {
                  
          if (value == 'boy') {
                      
          return "";
                  } 
          else {
                      
          return "";
                  }
              }
              
          var sm = new Ext.grid.CheckboxSelectionModel();
              
          var cm = new Ext.grid.ColumnModel([new Ext.grid.RowNumberer(), sm, {
                          header : '編號',
                          dataIndex : 'id',
                          width : 
          80,
                          sortable : 
          true
                      }, {
                          header : '名稱',
                          dataIndex : 'name',
                          width : 
          80
                      }, {
                          header : '性別',
                          dataIndex : 'sex',
                          renderer : renderSex
                      }, {
                          header : '日期',
                          dataIndex : 'date',
                          width : 
          100,
                          renderer : Ext.util.Format.dateRenderer('Y
          -m-d')
                      }, {
                          header : '描述',
                          dataIndex : 'descn',
                          width : 
          200
                      }]);
              
          var ds = new Ext.data.Store({
                          proxy : 
          new Ext.data.HttpProxy({
                                      url : '
          /ext/list.jspa'
                                  }),
                          reader : 
          new Ext.data.JsonReader({
                                      totalProperty : 'total',
                                      root : 'persons'
                                  }, [{
                                              name : 'id'
                                          }, {
                                              name : 'name'
                                          }, {
                                              name : 'sex'
                                          }, {
                                              name : 'date',
                                              type : 'date',
                                              dateFormat : 'Y
          -m-dTH:i:s'
                                          }, {
                                              name : 'descn'
                                          }])
                      });
              ds.load({
                          params : {
                              start : 
          0,
                              limit : 
          18
                          }
                      });
                      
              ds.on('beforeload',
          function(){
                Ext.apply(
                
          this.baseParams,
                {
                     title:Ext.get('title').dom.value
                });
              });

              
          var grid = new Ext.grid.GridPanel({
                          el : 'grid',
                          ds : ds,
                          cm : cm,
                          sm : sm,
                          border : 
          false,
                          autoExpandColumn : 
          5,
                          tbar : ['關鍵字查詢:', {
                                      xtype : 'textfield',
                                      width : 
          200,
                                      id : 'title',
                                      name : 'title'
                                  }, {
                                      text : '搜索',
                                      iconCls : 'search',
                                      handler : 
          function() {
                                          ds.load({
                                                      params : {
                                                          start : 
          0,
                                                          limit : 
          18,
                                                          title : Ext.get('title').dom.value
                                                      }
                                                  })
                                      }
                                  }, {
                                      xtype : 'tbseparator'
                                  }, {
                                      text : '發布',
                                      iconCls : 'edit'
                                  }, {
                                      xtype : 'tbseparator'
                                  }, {
                                      text : '查看',
                                      iconCls : 'copy'
                                  }, {
                                      xtype : 'tbseparator'
                                  }, {
                                      text : '刷新',
                                      iconCls : 'refresh'
                                  }, {
                                      xtype : 'tbseparator'
                                  }, {
                                      text : '回復',
                                      iconCls : 'post'
                                  }, {
                                      xtype : 'tbseparator'
                                  }, {
                                      text : '刪除',
                                      iconCls : 'del'
                                  }],
                          bbar : 
          new Ext.PagingToolbar({
                                      pageSize : 
          18,
                                      store : ds,
                                      displayInfo : 
          true,
                                      displayMsg : '第{
          0} 到 {1} 條數據 共{2}條',
                                      emptyMsg : '沒有數據'
                                  })
                      });
              grid.render();
          }
          Ext.onReady(listStudent);




          posted on 2008-11-12 22:32 HUIKK 閱讀(1395) 評論(0)  編輯  收藏 所屬分類: EXT
          主站蜘蛛池模板: 乌海市| 沽源县| 河东区| 东山县| 富顺县| 江永县| 山东省| 达州市| 桐柏县| 陈巴尔虎旗| 玛沁县| 饶河县| 左贡县| 青海省| 大宁县| 都兰县| 凯里市| 札达县| 德钦县| 阿克陶县| 德令哈市| 甘德县| 长寿区| 南靖县| 西乌珠穆沁旗| 金乡县| 兴山县| 辽阳市| 井研县| 饶河县| 灵山县| 河曲县| 兴山县| 洛南县| 丰县| 贵港市| 安乡县| 石阡县| 迁西县| 新巴尔虎右旗| 高雄县|