Passing an xtype to a col editor

January 6th, 2009
  • This doesn't seem to work. This is from the edit-grid.js example file. I substituted the editor for an xtype and I get an exception 'ed.render is not a function'. Any ideas on what I'm doing wrong here?

    var cm = new Ext.grid.ColumnModel([
    {
    id:'common',
    header: "Common Name",
    dataIndex: 'common',
    width: 220,
    editor: {'xtype': 'textfield'}
    }
    ...


  • if you'd looked at that feature request, i actually posted a working override for the ColumnModel to enable xtype support ;)

    glad you found a solution though. :)


  • If anyone's interested, I was able to get it to work like so:

    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);
    }
    }
    }


  • Thanks, in the meantime I guess just need to extend ColumnModel to check the component manager.


  • you can't define xtype-based grideditors at the moment.
    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


  • I believe editor must be wrapped with a gridEditor:

    var cm = new Ext.grid.ColumnModel([
    {
    id:'common',
    header: "Common Name",
    dataIndex: 'common',
    width: 220,
    editor: new Ext.grid.GridEditor({'xtype': 'textfield'})
    }


  • That's what I was thinking but the same example includes the following items which do not wrap the field with a GridEditor

    {
    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.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about Passing an xtype to a col editor , Please add it free.