Created
February 21, 2009 18:23
-
-
Save mxgrn/68120 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
CheckColumn plugin from the "Editable Grid" example on http://extjs.com/deploy/dev/examples/ | |
The problem with it is that when a new record is added to the store, the corresponding field value | |
is set to an empty string, instead of being set to false. Here's the fix for it. | |
*/ | |
Ext.grid.CheckColumn = function(config){ | |
Ext.apply(this, config); | |
if(!this.id){ | |
this.id = Ext.id(); | |
} | |
this.renderer = this.renderer.createDelegate(this); | |
}; | |
Ext.grid.CheckColumn.prototype ={ | |
init : function(grid){ | |
this.grid = grid; | |
this.grid.on('render', function(){ | |
var view = this.grid.getView(); | |
view.mainBody.on('mousedown', this.onMouseDown, this); | |
}, this); | |
}, | |
onMouseDown : function(e, t){ | |
if(t.className && t.className.indexOf('x-grid3-cc-'+this.id) != -1){ | |
e.stopEvent(); | |
var index = this.grid.getView().findRowIndex(t); | |
var record = this.grid.store.getAt(index); | |
record.set(this.dataIndex, !record.data[this.dataIndex]); | |
} | |
}, | |
renderer : function(v, p, record){ | |
/* SKOZLOV: v is the column value passed to the plugin. When new record is added, | |
this value is set to an empty string, hence it is also submitted as such, while it should be false. | |
Fixing it here. */ | |
if (typeof (v) == 'string' && v.length == 0) { | |
v = false; | |
record.data[this.dataIndex] = v; | |
}; | |
p.css += ' x-grid3-check-col-td'; | |
return '<div class="x-grid3-check-col'+(v?'-on':'')+' x-grid3-cc-'+this.id+'"> </div>'; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment