夢幻之旅

          DEBUG - 天道酬勤

             :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            671 隨筆 :: 6 文章 :: 256 評論 :: 0 Trackbacks
          var TG= Ext.extend(Ext.grid.GridPanel, {
                      sm : 
          null,
                      cm : 
          null,
                      data : 
          null,
                      ds : 
          null,
                      bb : 
          null,
                      
          // constructor function
                      constructor : function() {
                          
          this.sm = new Ext.grid.CheckboxSelectionModel();
                          
          this.cm = new Ext.grid.ColumnModel(
                              [
                                  
          new Ext.grid.RowNumberer(),
                                  
          this.sm,
                                  
          {header:'編號',dataIndex:'id',width:80,sortable:true},
                                  
          {header:'名稱',dataIndex:'name',width:80},
                                  
          {header:'性別',dataIndex:'sex',renderer:this.renderSex},
                                  
          {header:'日期',dataIndex:'date',width:100,renderer: Ext.util.Format.dateRenderer('Y 年m月d日')},
                                  
          {header:'描述',dataIndex:'descn',width:200}
                              ]);
                          
          this.data = [
                              ['
          1','name1','girl','1970-01-15T02:58:04','descn1'],
                              ['
          2','name2','boy','1970-01-15T02:58:04','descn2'],
                              ['
          3','name3','girl','1970-01-15T02:58:04','descn3'],
                              ['
          4','name4','girl','1970-01-15T02:58:04','descn4'],
                              ['
          5','name5','boy','1970-01-15T02:58:04','descn5']
                          ];
                          
          this.ds = new Ext.data.Store({
                              scope: 
          this,
                              proxy: 
          new Ext.data.MemoryProxy(this.data),
                              reader: 
          new Ext.data.ArrayReader({}, [
                                  
          {name: 'id'},
                                  
          {name: 'name'},
                                  
          {name: 'sex'},
                                  
          {name: 'date', type:'date',dateFormat:'Y-m-dTH:i:s'},
                                  
          {name: 'descn'}
                              ])
                          }
          );
                          
          this.ds.load();
                          
                          
          // split page bar
                          this.bb = new Ext.PagingToolbar({
                                      pageSize : 
          20,
                                      store : 
          this.ds,
                                      displayInfo : 
          true,
                                      displayMsg : '顯示第 
          {0} 條到 {1} 條記錄,一共 {2} 條',
                                      emptyMsg : 
          "沒有記錄"
                                  }
          );
                          
                          TG.superclass.constructor.call(
          this{
                              id : 'tg',
                              cm : 
          this.cm,
                              store : 
          this.ds,
                              sm : 
          this.sm,
                              
          //renderTo : "grid",
                              //autoHeight : true,
                              //autoWidth:true,
                              autoExpandColumn: 6,
                              loadMask : 
          {
                                  msg : '正在加載數(shù)據(jù),請稍候'
                              }
          ,
                              autoScroll : 
          true,
                              bbar: 
          this.bb
                          }
          );
                      }
          ,
                      
                      renderSex : 
          function (value) {
                          
          if (value == 'boy') {
                              
          return "<span style='color:red; font-weight:bold;'>男</span>";
                          }
           else {
                              
          return "<span style='color:green; font-weight:bold;'>女</span>";
                          }

                      }

                  }
          );
                  
                  Ext.onReady(
          function(){
                  
          var centerAreaTabPanel = new Ext.TabPanel({
                          id: 'centerArea',
                          renderTo:'grid_test',
                          deferredRender: 
          false,
                          activeTab: 
          0,
                          enableTabScroll: 
          true,
                          width : 
          1000,
                          height : 
          600,
                          items: [
          {
                              title: 'WELLCOME',
                              plain:
          true,
                              border:
          false,
                              frame:
          true,
                              layout:'fit',
                              items : [
          new TG()]
                          }
          ]
                      }
          );
                  }
          ); 
          posted on 2010-11-26 21:38 HUIKK 閱讀(232) 評論(0)  編輯  收藏 所屬分類: EXT
          主站蜘蛛池模板: 鄯善县| 定州市| 南皮县| 阿勒泰市| 天津市| 云安县| 天气| 靖边县| 类乌齐县| 驻马店市| 濉溪县| 固安县| 威信县| 乌什县| 邢台县| 长治县| 桂东县| 冕宁县| 五峰| 台东县| 洮南市| 家居| 元阳县| 乌兰县| 万州区| 平潭县| 东乌| 望城县| 抚顺县| 门头沟区| 浦北县| 吉安市| 乌苏市| 柘荣县| 永善县| 昭苏县| 汽车| 乡宁县| 枞阳县| 珠海市| 丹棱县|