1. #1
    Sencha Premium Member
    Join Date
    Mar 2012
    Posts
    13
    Vote Rating
    0
    summer980824 is on a distinguished road

      0  

    Default How to apply various types of editors for a single column in Ext4?

    How to apply various types of editors for a single column in Ext4?


    Hi,

    I am trying to upgrade Ext3.4 codes to Ext4.1 and I have encountered a problem that it seems there is no config for a column to set multiple editors.

    In Ext3, it works like this way:
    Code:
    new Ext.grid.ColumnModel({
        scope    :    this,
        columns :     this.columns,
        editors :     {
            'ReadOnly'     :    null,
            'String'    :    new Ext.grid.GridEditor(new Ext.form.TextField({})),
            'Number'    :    new Ext.grid.GridEditor(new Ext.form.NumberField({}))
        },
        getCellEditor : function(colIndex, rowIndex)
        {    //    get editor 
            var field = this.getDataIndex(colIndex);
            if(field == 'value')
            {
                var rec = this.scope.configStore.getAt(rowIndex);
                return this.editors[rec.get('type')];
            }
            return Ext.grid.ColumnModel.prototype.getCellEditor.call(this,
                    colIndex, rowIndex);    //    default.
        }
    });
    Then the editor of each cell will be set automatically according to its 'type', even they are in the same column.

    However, there is only one editor for each column in Ext4, so how can I accomplish this function?

    I have tried to set different editors in the renderer function of the column, but it seems only the last editor will be applied for the whole column...

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,085
    Vote Rating
    467
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    You can use the following .. set your condition as needed.

    Code:
    beforeedit: function(ed, context){
        var field = { xtype: 'textfield' };
        grid.headerCt.items.getAt(3).setEditor(field);
    }
    Scott.

Thread Participants: 1

Tags for this Thread