Passing an xtype to a col editor
January 6th, 2009
var cm = new Ext.grid.ColumnModel([
{
id:'common',
header: "Common Name",
dataIndex: 'common',
width: 220,
editor: {'xtype': 'textfield'}
}
...
glad you found a solution though. :)
DynamicColumnModel = Ext.extend(Ext.grid.ColumnModel, {
setConfig : function(config, initial){
for(var i = 0, len = config.length; i < len; i++){
var c = config[i];
if(c.editor && c.editor.xtype){
c.editor = Ext.ComponentMgr.create({xtype:c.editor.xtype}, null);
}
DynamicColumnModel.superclass.setConfig.call(this, config, initial);
}
}
}
you'll need to pass in actual Ext.form.Field objects to the ColumnModel config (which is what you're seeing in the examples already), which are then internally wrapped in GridEditors by the ColumnModel's setConfig method.
on a side-note, i've already put up a feature request some days back regarding this:
http://extjs.com/forum/showthread.php?t=38192
var cm = new Ext.grid.ColumnModel([
{
id:'common',
header: "Common Name",
dataIndex: 'common',
width: 220,
editor: new Ext.grid.GridEditor({'xtype': 'textfield'})
}
{
header: "Light",
dataIndex: 'light',
width: 130,
editor: new Ext.form.ComboBox({
typeAhead: true,
triggerAction: 'all',
transform:'light',
lazyRender:true,
listClass: 'x-combo-list-small'
})
},{
header: "Price",
dataIndex: 'price',
width: 70,
align: 'right',
renderer: 'usMoney',
editor: new fm.NumberField({
allowBlank: false,
allowNegative: false,
maxValue: 100000
})
}
#If you have any other info about this subject , Please add it free.# |