2012-02-29 21 views
1

我有一個網格與檢查列和檢查列閱讀我的數據,但我不能設置它,我想知道如何設置它簡單的方法。 我希望我的檢查欄成爲視圖只在我的網格數據如何設置它?下面 是我的示例代碼:如何將Extjs.grid.CheckColumn設置爲僅用於只讀?

var chkColH = new Ext.grid.CheckColumn({ 
    header: ' H', 
    dataIndex: 'testing', 
    resizable:false, 
    disabled :true, //***I wan to disabled this check column in my grid for view only 
    width: 25 
}); 

colModel=new Ext.grid.ColumnModel([ 
    chkColH 
]); 


     xtype:'editorgrid', 
     id:'theGrid', 
     stripeRows:true, 
     store:gridStore, 
     colModel:colModel, 
     trackMouseOver:false, 
     columnLines:true, 
     enableColumnMove:false, 
     enableHdMenu:false, 
     frame:true, 
     disableSelection:true, 
     plugins: [chkColH], 
     sm:chkSM 
+0

看到答案在http://stackoverflow.com/questions/11440216工作液/ how-do-i-disable -a-control-in-an-extjs-grid – peter 2015-03-03 10:37:45

回答

2

您可以覆蓋onmousedown事件什麼也不做在CheckColumn

var chkColH = new Ext.grid.CheckColumn({ 
    header: ' H', 
    dataIndex: 'testing', 
    resizable:false, 
    width: 25, 
    onMouseDown : function(e, t){} 
}); 
+0

thankz for sharing – user983738 2012-03-01 02:51:00

+3

onMouseDown:'Ext.emptyFn'縮寫爲:-) – Francesco 2012-03-02 22:43:29

+0

對ExtJs 3.3.1不起作用 – peter 2015-03-03 10:37:08

1

在checkcolumn配置添加此事件:

processEvent: function() { return false; } 
+0

感謝名單。這應該是最好的答案。適用於extjs 5.0.1。 'processEvent:Ext.emptyFn' – Arvin 2014-08-13 07:19:05

4

var chkColH = new Ext.grid.CheckColumn({ header: 'Rerun', dataIndex: 'rerun', resizable:false, width: 25, disabled : true, disabledCls : 'x-item-enabled' });

4

添加到您的代碼庫,並使用「readonlycheckcolumn」的xtype,而不是「checkcolumn」(與分機4.2測試):

Ext.define('Ext.grid.column.ReadOnlyCheckColumn', { 
    extend: 'Ext.grid.column.CheckColumn', 
    alias: 'widget.readonlycheckcolumn', 
    requires: ['Ext.grid.column.CheckColumn'], 
    listeners: { beforecheckchange: function() { return false; } } 
});