2011-04-15 72 views
0

我有一個自定義'類',它擴展了Ext.grid.GridPanel。我想有一列複選框(example which uses Ext.ux.grid.CheckboxColumn - 只是我需要的東西)。 我的目標是與預先生成的配置對象,包括列模型(它是由一個PHP腳本生成的)使用它,所以我重載initComponent方法添加在它裏面列:ExtJS:添加複選框列「即時」

MyGrid = Ext.extend 
(
    Ext.grid.GridPanel 
    ,{ 
     initComponent : function() 
     { 
      this.columns.push({ 
       xtype  : 'checkcolumn' 
       ,header  : 'Show on map ?' 
       ,dataIndex : 'showonmap' 
       ,width  : 130 
      }); 

      Ext.apply(this, {columns:this.columns}); 
      MyGrid.superclass.initComponent.apply(this, arguments); 
     } 
    } 
); 

這樣的事情與合作ActionColumn組件,但是這段代碼失敗了,因爲它找不到構造函數(可能是CheckColumn)。

我應該如何修改我的代碼或CheckColumn使這件事情起作用?

在此先感謝!

回答

2

如果找不到構造函數,則不能正確導入CheckColumn類。試試這個,看看構造函數可以直接發現:

MyGrid = Ext.extend 
(
    Ext.grid.GridPanel 
    ,{ 
     initComponent : function() 
     { 
      this.columns.push(new Ext.ux.grid.CheckColumn({ 
       ,header  : 'Show on map ?' 
       ,dataIndex : 'showonmap' 
       ,width  : 130 
      })); 

      Ext.apply(this, {columns:this.columns}); 
      MyGrid.superclass.initComponent.apply(this, arguments); 
     } 
    } 
); 

如果你得到一個異常Ext.ux.grid.CheckColumn is not a constructor,那麼你肯定知道的類是不繳費。確保你已經正確地包含了該類,並且可以使用Firebug驗證該源是否實際包含並可用。