-
7 Dec 2009 9:47 AM #1
Ext.ux.grid.CheckboxColumn
Ext.ux.grid.CheckboxColumn
Demo here
Download

PHP Code:Ext.ns('Ext.ux.grid');
/**
* A Column definition class which renders enum data fields.
* @class Ext.ux.grid.CheckboxColumn
* @extends Ext.grid.Column
* @author Tran Cong Ly - tcl_java@yahoo.com - http://5cent.net
* Create the column:
*
var cm = new Ext.grid.ColumnModel([
new Ext.ux.grid.CheckboxColumn({
header: 'Header #1',
dataIndex: 'field_name_1'
},
{
xtype: 'checkboxcolumn',
header: 'Header #2',
dataIndex: 'field_name_2',
on: 1,
off: 0
},
{
xtype: 'checkboxcolumn',
header: 'Header #3',
dataIndex: 'field_name_3',
on: 'abc',
off: 'def'
}])
*/
Ext.ux.grid.CheckboxColumn = Ext.extend(Ext.grid.Column, {
on: true,
off: false,
constructor: function (cfg) {
Ext.ux.grid.CheckboxColumn.superclass.constructor.call(this, cfg);
this.editor = new Ext.form.Field();
var cellEditor = this.getCellEditor(),
on = this.on,
off = this.off;
cellEditor.on('startedit', function (el, v) {
cellEditor.setValue(String(v) == String(on) ? off : on);
cellEditor.hide();
});
this.renderer = function (value, metaData, record, rowIndex, colIndex, store) {
metaData.css += ' x-grid3-check-col-td';
return '<div class="x-grid3-check-col' + (String(value) == String(on) ? '-on' : '') + '"></div>';
}
}
});
Ext.grid.Column.types['checkboxcolumn'] = Ext.ux.grid.CheckboxColumn;
-
13 Feb 2010 5:06 AM #2
use this:
instead of:Code:this.editor = new Ext.grid.GridEditor(new Ext.form.Field());
btw.thank you for sharing this code!Code:this.editor = new Ext.form.Field();
Last edited by mystix; 13 Feb 2010 at 10:02 AM. Reason: POST CODE IN [code][/code] TAGS. see http://extjs.com/forum/misc.php?do=bbcode#code
-
14 Feb 2010 2:02 AM #3
Or even better:
Code:this.editor = new Ext.grid.GridEditor(new Ext.form.Checkbox());

-
14 Feb 2010 8:08 AM #4
if defined "on" and "off" parameters are others then true or false than you should use
if defined "on" and "off" parameters are default true or false,Code:this.editor = new Ext.grid.GridEditor(new Ext.form.Field());
and you do not want to see editor field, than use
Code:this.editor = new Ext.grid.GridEditor(new Ext.form.Checkbox());

-
16 Mar 2010 7:16 AM #5
-
16 Mar 2010 7:33 AM #6
-
16 Apr 2010 5:59 PM #7
greate job, that helps me a lot!
thanks tcl_java

-
16 May 2010 12:54 PM #8
this is really very useful extension.. Thanks a lot for sharing tcl_java.




Reply With Quote