Ext.extend()的运用

 
 FormSet_Tabpage_SimpleSelGrid= Ext.extend(Ext.grid.GridPanel,{
            selwindow:null,
            constructor:function(obj){
                     //  if (this.selwindow ==null ) selwindow= new FormSet_Tabpage_SimpleSelGridWindow( obj );         
                     FormSet_Tabpage_SimpleSelGrid.superclass.constructor.call(this,{
                                                                        plain:true,
                                                                        basecls:'x-plain',
                                                                        bodyStyle : 'padding:6px', 
                                                                        store: obj.gridstore,  //动态store
                                                                        cm: obj.gridcm,   //动态cm
                                                                        autoHeight :true,
                                                                        autoWidth:true, 
                                                                        trackMouseOver:false,
                                                                        viewConfig: {forceFit: true  }, 
                                                                        loadMask: true, 
                                                                        autoScroll:true ,
                                                                        windowLock:false,
                                                                        listeners:{  
                                                                                     celldblclick:function(){alert(99); this.rowdblclick }
                                                                  }, 
                                                                        bbar: new Ext.PagingToolbar({
                                                                       pageSize: obj.gridpageSize,  //动态每页显示数
                                                                       store:  obj.gridstore,       //动态store
                                                                       displayInfo: true,
                                                                       displayMsg: '第{0}-{1}条记录 共{2}',
                                                                       emptyMsg: "没有记录信息"
                                                                       }),
                                                                        sm: new Ext.grid.RowSelectionModel({
                                                                                    singleSelect:true
                                                                             })                    
                                                                });
                                                               
                 },
        rowdblclick:function(){
                alert(88);
        }           
    }) ;
 
 FormSet_Tabpage_SimpleSelGridWindow=Ext.extend(Ext.Window,{
  selgrid: null, //new FormSet_Tabpage_SimpleSelGrid(obj),
  constructor:function( obj ){
                      this.selgrid = new FormSet_Tabpage_SimpleSelGrid(obj);
             FormSet_Tabpage_SimpleSelGridWindow.superclass.constructor.call(this,{
                                                 plain:true,
                                                 title:"选择窗口",
                                                 closeAction :'hide',
                                                 autoScroll:true ,
                                                 width:300,
                                                 modal:true,
                                                 height:400,
                                                 items:  this.selgrid ,
                                                 buttons:[ {
                                                             text:'确定',
                                                             handler:this.onSubmitclick ,
                                                             scope:this },
                                                            {
                                                             text:'取消',
                                                             handler:this.onCancelclick,
                                                             scope:this
                                                            }
                                                         ]
                                                         }) ;
          this.addEvents("submit"); //构造函数中添加事件                                           
                }, //end function 
  close:function(){
                 this.hide();
               },
     onSubmitclick:function(){
                   var gridrec= this.selgrid.getSelectionModel().getSelected() ;
                   this.fireEvent("submit",this, gridrec ) ; //添加事件
                   //alert( Ext.encode( gridrec.data ) )
                   this.close();
                  } ,
     onCancelclick:function(){
                    alert(999);
                    this.close();
                  }   
 
})

你可能感兴趣的:(extend)