PDA

View Full Version : [FIXED-546][3.1.1] Can't use a single instance of an editor field in EditorGridPanel



elishnevsky
9 Feb 2010, 12:35 PM
In version 3.1.0 I could reuse a single instance of a Field in multiple columns in EditorGridPanel. After upgrading to version 3.1.1 it no longer works. Once you go into edit mode in one of the columns, the editor field will ONLY shows up in the cells of that column.

Browser: ANY.
Operating System: ANY

Just copy the following code and run it.

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>test</title>
<link type="text/css" rel="stylesheet" href="http://extjs.cachefly.net/ext-3.1.1/resources/css/ext-all.css"/>
<script type="text/javascript" src="http://extjs.cachefly.net/ext-3.1.1/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="http://extjs.cachefly.net/ext-3.1.1/ext-all-debug.js"></script>
<script type="text/javascript">
Ext.onReady(function() {
var data = [
['Allan','Charboneau'],
['Lance','Weedon'],
['Nelson','Samayoa'],
['Allyson','Eaddy'],
['Penelope','Boehman'],
['Hugh','Riggio'],
['Nita','Seaberry'],
['Cody','Alejos'],
['Lenore','Ellefson'],
['Darren','Marcantonio']
];

var editor = new Ext.form.TextField();

new Ext.grid.EditorGridPanel({
store: new Ext.data.ArrayStore({
fields: ['fname', 'lname'],
data: data
}),
columns: [
{header: 'First Name', dataIndex: 'fname', editor: editor},
{header: 'Last Name', dataIndex: 'lname', editor: editor}
],
title: 'EditorGrid',
width: 300,
height: 300,
renderTo: document.body
});
});
</script>
</head>
<body>
</body>
</html>

Sorry, I haven't done any debugging. Have no time.

elishnevsky
9 Feb 2010, 8:09 PM
After some debugging and comparing files between v3.1.0 and v3.1.1 here's the suggested fix:


Ext.override(Ext.grid.Column, {
/**
* Sets a new editor for this column.
* @param {Ext.Editor/Ext.form.Field} editor The editor to set
*/
setEditor : function(editor){
if(this.editor){
this.editor.destroy();
}
this.editor = null;
if(editor){
//not an instance, create it
if(!editor.isXType){
editor = Ext.create(editor, 'textfield');
}
//check if it's wrapped in an editor
if(!editor.startEdit){
// editor = new Ext.grid.GridEditor(editor);
if(!editor.gridEditor){
editor.gridEditor = new Ext.grid.GridEditor(editor);
}
this.editor = editor.gridEditor;
} else {
this.editor = editor;
}
}
}
});
Green - old code, can be deleted
Red - new code

elishnevsky
11 Feb 2010, 6:34 PM
Sorry for bumping, but can someone add this fix to SVN please?

evant
11 Feb 2010, 6:37 PM
We've got a ticket open, it will be addressed, keep using your override for now.

Jamie Avins
16 Feb 2010, 1:22 PM
Fixed in SVN 6088.