-
30 Oct 2011 6:24 AM #1
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:
column.getEditor is not a functionPHP Code:var my_grid = Ext.getCmp("my_grid");
var myEditor = my_grid.columns[0].getEditor();
my_grid.columns[3].setEditor(myEditor);
http://localhost/javascripts/ext/ext-all-debug.js
Line 79363
in source code,
my ExtJS version is 4.0.7 and the same problem in 4.0.2PHP Code:field = column.getEditor(null, {
xtype: 'displayfield',
getModelData: function() { //<-this line is 79363
return null;
}
});
-
31 Oct 2011 3:50 AM #2
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
In this function you return the appropriate editor (I did it according to the column type)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) }
This is how you create your editors :Code:getCellEditor : function(record, column) { return this.editors[record.get('type')]; }
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' ] ] }) }) };
-
31 Oct 2011 4:52 PM #3
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 Nov 2011 1:37 AM #4
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...
-
4 Nov 2011 4:50 PM #5
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 Mar 2012 8:39 AM #6
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();


Reply With Quote