Extjs 3.4 checkchange listener not working on Checkcolumn

The checkchange listener for my checkColumn is not working. Any ideas why not?

var checked = new Ext.grid.CheckColumn({
  header: 'Test',
  dataIndex: 'condition',
  renderer: function(v,p,record){
        var content = record.data['info'];      
        if(content == 'True'){
              p.css += ' x-grid3-check-col-td'; 
            return '<div class="x-grid3-check-col'+(v?'-on':'')+' x-grid3-cc-'+this.id+'"> </div>';
        }

  },    
  listeners:{
        checkchange: function(column, recordIndex, checked){
              alert("checked");
        }

  }

});
+5
source share
3 answers

In ExtJS 3, the checkcolumn plugin does not actually use the ExtJS flag component, so flag events are not available. The control column is simply an extended column that a custom renderer has added to create a cell as a checkbox.

By default, the only events you can listen to are Ext.grid.Column events ( click , contextmenu , dblclick, and mousedown ).

, CheckColumn beforecheckchange checkchange.

0

Ext.ux.grid.CheckColumn , checkchange:

initComponent: function(){
  Ext.ux.grid.CheckColumn.superclass.initComponent.call(this);

  this.addEvents(
    'checkchange'
  );
},

in processEvent :

processEvent : function(name, e, grid, rowIndex, colIndex){
  if (name == 'mousedown') {
    var record = grid.store.getAt(rowIndex);
    record.set(this.dataIndex, !record.data[this.dataIndex]);

    // Fire checkchange event
    this.fireEvent('checkchange', this, record.data[this.dataIndex]);

    return false; // Cancel row selection.
  } else {
    return Ext.grid.ActionColumn.superclass.processEvent.apply(this, arguments);
  }
},

CheckColumn :

  Ext.ns('Ext.ux.grid');

  Ext.ux.grid.CheckColumn = Ext.extend(Ext.grid.Column, {
    // private
    initComponent: function(){
      Ext.ux.grid.CheckColumn.superclass.initComponent.call(this);

      this.addEvents(
        'checkchange'
      );
    },

    processEvent : function(name, e, grid, rowIndex, colIndex){
      if (name == 'mousedown') {
        var record = grid.store.getAt(rowIndex);
        record.set(this.dataIndex, !record.data[this.dataIndex]);

        this.fireEvent('checkchange', this, record.data[this.dataIndex]);

        return false; // Cancel row selection.
      } else {
        return Ext.grid.ActionColumn.superclass.processEvent.apply(this, arguments);
      }
    },

    renderer : function(v, p, record){
      p.css += ' x-grid3-check-col-td'; 
      return String.format('<div class="x-grid3-check-col{0}">&#160;</div>', v ? '-on' : '');
    },

    // Deprecate use as a plugin. Remove in 4.0
    init: Ext.emptyFn
  });

  // register ptype. Deprecate. Remove in 4.0
  Ext.preg('checkcolumn', Ext.ux.grid.CheckColumn);

  // backwards compat. Remove in 4.0
  Ext.grid.CheckColumn = Ext.ux.grid.CheckColumn;

  // register Column xtype
  Ext.grid.Column.types.checkcolumn = Ext.ux.grid.CheckColumn;
0

Simple answer

Check the box or clear the box when the user clicks on the checkbox in the extjs 3 grid. Use this property in the grid: => columnPlugins: [1, 2], I believe that this property is used in your code, it does a great job.

xtype:grid,
columnPlugins: [1, 2],
0
source

All Articles