1. #1
    Sencha User hexawing's Avatar
    Join Date
    Nov 2009
    Posts
    73
    Answers
    1
    Vote Rating
    0
    hexawing is on a distinguished road

      0  

    Default Unanswered: Report error "column.getEditor is not a function" when I setEditor to a column?

    Unanswered: Report error "column.getEditor is not a function" when I setEditor to a column?


    My code is like this:

    PHP Code:
    var my_grid Ext.getCmp("my_grid");
    var 
    myEditor my_grid.columns[0].getEditor();
    my_grid.columns[3].setEditor(myEditor); 
    column.getEditor is not a function
    http://localhost/javascripts/ext/ext-all-debug.js
    Line 79363

    in source code,
    PHP Code:
            field column.getEditor(null, {
                  
    xtype'displayfield',
                 
    getModelData: function() { //<-this line is 79363
                     
    return null;
                  }
              }); 
    my ExtJS version is 4.0.7 and the same problem in 4.0.2

  2. #2
    Sencha User lucasguaru's Avatar
    Join Date
    May 2011
    Location
    Guarujá, Brazil
    Posts
    77
    Answers
    9
    Vote Rating
    1
    lucasguaru is on a distinguished road

      0  

    Default


    Looks like you're trying to use the same editor for two columns. Is that right?
    If so, what you have to do is bind your function to the column
    Code:
    {
        text : "Valor",
        name : 'colunaValor',
        //width : 75,
        sortable : true,
        dataIndex : 'valor',
        width : 180,
        renderer : Ext.Function.bind(this.renderCell, this),
        getEditor : Ext.Function.bind(this.getCellEditor, this)
    }
    In this function you return the appropriate editor (I did it according to the column type)
    Code:
    getCellEditor : function(record, column) {
            return this.editors[record.get('type')];
        }
    This is how you create your editors :
    Code:
    this.editors = {
        'date' : Ext.create('Ext.grid.CellEditor', {
            field : Ext.create('Ext.form.field.Date', {
                //allowBlank : false,
                selectOnFocus : true
            })
        }),
        'string' : Ext.create('Ext.grid.CellEditor', {
            field : Ext.create('Ext.form.field.Text', {
                //allowBlank : false,
                selectOnFocus : true
            })
        }),
        'number' : Ext.create('Ext.grid.CellEditor', {
            field : Ext.create('Ext.form.field.Number', {
                //allowBlank : false,
                selectOnFocus : true
            })
        }),
        'int' : Ext.create('Ext.grid.CellEditor', {
            field : Ext.create('Ext.form.field.Number', {
                //allowBlank : false,
                selectOnFocus : true
            })
        }),
        'boolean' : Ext.create('Ext.grid.CellEditor', {
            allowBlank : false,
            field : Ext.create('Ext.form.field.ComboBox', {
                editable : false,
                store : [ [ true, 'Sim' ], [ false, 'Não' ] ]
            })
        })
    };

  3. #3
    Sencha User hexawing's Avatar
    Join Date
    Nov 2009
    Posts
    73
    Answers
    1
    Vote Rating
    0
    hexawing is on a distinguished road

      0  

    Default


    Emm, perhaps my expression is incorrect...I just want to set a different editor to a column, but I don't know what kind of "editor" should I write(no matter how I wrote the editor, I got the same error), so I tried to get an editor from other column. And it didn't work either...

  4. #4
    Sencha User hexawing's Avatar
    Join Date
    Nov 2009
    Posts
    73
    Answers
    1
    Vote Rating
    0
    hexawing is on a distinguished road

      0  

    Default


    In firebug, I found this about the "column"'s property:

    $className "Ext.form.field.Text"

    sure it hasn't the "setEditor" method. In API, setEditor is a method of Ext.grid.column.Column, so I think this is a bug...

  5. #5
    Sencha User hexawing's Avatar
    Join Date
    Nov 2009
    Posts
    73
    Answers
    1
    Vote Rating
    0
    hexawing is on a distinguished road

      0  

    Default


    http://jsfiddle.net/hexawing/mf2jH/5/

    As the code snippet above, is my commented code correct? It cannot work if I uncomment that line.

    Can anyone help me?

  6. #6
    Sencha Premium Member
    Join Date
    Jun 2010
    Posts
    11
    Vote Rating
    0
    taylon is on a distinguished road

      0  

    Default


    I'm positive this is not a best practice method (especially after all the "use itemId instead of id" posts), but I've found you can give the editor of the column an id and just reference that. Below is some rough example code to dynamically set a column to allowBlank or not. It should work for anything that goes into the editor. Just get the id, set the property, and doComponentLayout() on the grid.

    Incidentally it looks like my issue might be fixed in 4.1 http://www.sencha.com/forum/showthre...iting&langid=1 but since it's still beta I can't swap over to it just yet.

    Hope it helps.

    Code:
    var myGrid = Ext.create('Ext.grid.Panel', {
        plugins: [rowEditing],
        width: '100%',
        height: 450,
        store: myStore,
        id: 'myGrid',
        columnLines: true,
        columns: [{
            text: 'My Column Text',
             itemId: 'myColumn',
            dataIndex: 'myData',
            editor: {
                xtype: 'textfield',
                id: 'myColumnEditor'
            }]
    });
    
    // Do stuff begin
    // ...
    // Do stuff end
    
    if (someVariable === 'Blah' ) {
         Ext.getCmp('myColumnEditor').allowBlank = true;
    else
         Ext.getCmp('myColumnEditor').allowBlank = false;
    }
    
    Ext.getCmp('myGrid').doComponentLayout();

Thread Participants: 2

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar