梦幻之旅

DEBUG - 天道酬勤

   :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  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 : '正在加载数据,请稍候'
                    }
,
                    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 阅读(151) 评论(0)  编辑  收藏 所属分类: EXT

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


网站导航: