Hi!
I have to write a custom event (click event) that have to execute the default event code, and then execute custom code.
I defined a custom gridcolumn:
Code:
Ext.grid.CheckColumn = function(config){ this.addEvents("click"); Ext.grid.CheckColumn.superclass.constructor.call(this); Ext.apply(this, config, { onClick: function(obj,evt) { var index = evt.row; var record = evt.grid.store.getAt(index); var arrValue = obj.checkValue; var v = record.get(this.dataIndex); if(arrValue[0]==v) { v = arrValue[1]; } else { v = arrValue[0]; } record.set(this.dataIndex, v); }, renderer : function(v, p, record){ this.on('mousedown', this.onMouseDown, this); this.on('click', this.onClick, this); if (record.get(record.store.reader.meta.id)=='' && v=='' && record.dirty) { v = this.initValue; } var checkV = '@@@@'; if (this.checkValue[0]!=null) { checkV = this.checkValue[0]; } var html = "<input type='hidden' name='"+this.id+"' id='" + Ext.id() + "' value='"+v+"' />"; html += "<div class='x-grid3-check-col"+(v==checkV?'-on':'')+" x-grid3-cc-"+this.id+"'></div>"; return html; } }); if(!this.id){ this.id = Ext.id(); } this.renderer = this.renderer.createDelegate(this); };
In a specific column I have to execute the default click code, but then execute some custom code.
Now I have this code to do this:
Code:
   listeners: {
    onClick: function(obj,evt) {
                var index = evt.row;
                var record = evt.grid.store.getAt(index);
       var arrValue = obj.checkValue;
       var v = record.get(this.dataIndex);
       if(arrValue[0]==v) {
        v = arrValue[1];
       } else {
        v = arrValue[0];
       }
                record.set(this.dataIndex, v);
           // now custom code
           ....
    }
   }
is there a way to not rewrite the same code?
thanks!