Search code examples
javascriptextjsextjs4extjs3

Extjs: only show checkbox when another field has a value


i have a grid with a checkboxcolumn, all works fine but i would like to only show the checkbox if another field has a certain value. I work with version 3.3.1 but i guess that an example from another version would get me started. If not possible, disabling the checkbox would also be fine. Do i have to do that in a renderer or a listener and how ?

var checkColumn = new Ext.grid.CheckColumn({ 
 header: 'Checklist OK ?',  
 dataIndex: 'checklist_ok',  
 width: 20, 
 align: 'center' 
}); 

cmDiverse = new Ext.grid.ColumnModel({ 
 defaults: {"sortable": true, "menuDisabled":false, "align":"right"}, 
 store: storeDiverse, 
 columns: [ 
   {"id":"id", "header": "id", "hidden": true, "dataIndex": "id", "width": 20}, 
   checkColumn, 
   ... 

gridDiverse = new Ext.ux.grid.livegrid.EditorGridPanel({ 
  id              : "gridDiverse", 
  enableDragDrop  : false, 
  loadMask        : true, 
  clicksToEdit    : 1, 
  layout          :'anchor', 
  cm              : cmDiverse, 
  .... 

Solution

  • Found it myself, added the following renderer to checkColumn

    renderer : function(v, p, record){
      var type3m = record.get('type3m');
      if ((['6M','11e']).indexOf(String(type3m)) != -1){ //if the field type3m contains certain values
        p.css += ' x-grid3-check-col-td'; 
        return '<div class="x-grid3-check-col'+(v?'-on':'')+' x-grid3-cc-'+this.id+'"> </div>';
      }
    }