PDA

View Full Version : [FIXED] Setting TextField value in beforeedit event does not work in 4.2.2



ihands
31 Oct 2013, 7:19 AM
I have a grid with cellediting and a column with a renderer to display different text than the dataIndex value. Since the value in the column is different from the dataIndex in the record, when I invoke the texteditor on that cell I want to change the value that shows up in the texteditor to match what is in the cell. This was working in 4.2.1 but now the value I set for the texteditor in the beforeedit event does not show up. Is there some new behavior in 4.2.2 for beforedit that I should know about ?

Using the code below, dbl-click the "Some Text" cell and you will see the value "Dummy Value" in the text editor, it should say "Some Text".



Ext.define('MyApp.view.MyViewport', {
extend: 'Ext.container.Viewport',


initComponent: function() {
var me = this;


Ext.applyIf(me, {
items:
[
{
xtype: 'gridpanel',
store:
{
data:
[
{
text: 'Some Text',
dummy: 'Dummy Value'
}
],
proxy:
{
type: 'memory'
},
fields: ['text', 'dummy'],
},
columns:
[
{
xtype: 'gridcolumn',
dataIndex: 'dummy',
editor:
{
xtype: 'textfield'
},
renderer: function(value, metaData, record, row, columnIndex, store, gridView)
{
return record.get("text");
}
}
],
plugins:
[
{
ptype: 'cellediting',
listeners:
{
beforeedit: function(editor, editEvent, options)
{
editEvent.value = editEvent.record.get('text');
}
}
}
]
}
]
});


me.callParent(arguments);
}


});

Gary Schlosberg
31 Oct 2013, 9:19 AM
Sounds a little like this (http://www.sencha.com/forum/showthread.php?272590) issue, but I haven't been able to reproduce it. I added your code to this fiddle, though you won't be able to run it in 4.2.2:
https://fiddle.sencha.com/#fiddle/1ac

ihands
31 Oct 2013, 9:33 AM
Thanks for the reply, but the issue you referenced, EXTJSIV-11376, looks different. Notice in my code I am explicitly setting the editEvent.value but it is being ignored after the beforeedit event returns.

Are you saying that you cannot reproduce the problem in 4.2.2 ? It breaks consistently in 4.2.2, while it works consistently in 4.2.1.

Gary Schlosberg
31 Oct 2013, 11:02 AM
Yes, I've been unable to reproduce in any version. Here's another fiddle which is truer to your example code.
https://fiddle.sencha.com/#fiddle/1ae

With my access level, I'm able to run it against 4.2.2 and the latest nightlies, but it always displays "Some Text". I also ran both of these test cases independently of fiddle in various browsers but couldn't recreate the behavior. In which browser are you seeing this?

ihands
31 Oct 2013, 11:48 AM
Maybe there is something in Fiddle that is fiddling with the code, I see it every time on Firefox 24, Chrome, and Safari. I am using the commercial extjs 4.2.2.1144. Attached below is the actual html file with everything I am using to reproduce. Can you use this code and see if you can reproduce it outside of Fiddle with a 4.2.2.114 build please ?


<html><head>
<script src="../ext-4.2.2.1144/ext-all.js"></script>
<link rel="stylesheet" href="../ext-4.2.2.1144/resources/ext-theme-classic/ext-theme-classic-all.css">
<script type="text/javascript">
Ext.Loader.setConfig({
enabled: true
});


Ext.application({
stores: [

],
views: [
'MyViewport'
],
autoCreateViewport: true,
name: 'MyApp'
});


Ext.define('MyApp.view.MyViewport', {
extend: 'Ext.container.Viewport',


initComponent: function() {
var me = this;


Ext.applyIf(me, {
items:
[
{
xtype: 'gridpanel',
store:
{
data:
[
{
text: 'Some Text',
dummy: 'Dummy Value'
}
],
proxy:
{
type: 'memory'
},
fields: ['text', 'dummy'],
},
columns:
[
{
xtype: 'gridcolumn',
dataIndex: 'dummy',
editor:
{
xtype: 'textfield'
},
renderer: function(value, metaData, record, row, columnIndex, store, gridView)
{
return record.get("text");
}
}
],
plugins:
[
{
ptype: 'cellediting',
listeners:
{
beforeedit: function(editor, editEvent, options)
{
editEvent.value = editEvent.record.get('text');
}
}
}
]
}
]
});


me.callParent(arguments);
}


});
</script>
</head>
<body></body>
</html>

Gary Schlosberg
31 Oct 2013, 3:11 PM
As mentioned, I did try the code outside of fiddle as well. That said, I tried the HTML file from your most recent post, but it wouldn't run. I removed the autoCreateViewport config and added the launch config, and now it runs, but I still see "Some Text" in all browsers I've tried.




<html>

<head>
<script src="/builds/extjs/4.2.2.1144/ext-all.js"></script>
<link rel="stylesheet" href="/builds/extjs/4.2.2.1144/resources/ext-theme-classic/ext-theme-classic-all.css">
<script type="text/javascript">
Ext.Loader.setConfig({
enabled: true
});

Ext.define('MyApp.view.MyViewport', {
extend: 'Ext.container.Viewport',


initComponent: function () {
var me = this;


Ext.applyIf(me, {
items: [{
xtype: 'gridpanel',
store: {
data: [{
text: 'Some Text',
dummy: 'Dummy Value'
}],
proxy: {
type: 'memory'
},
fields: ['text', 'dummy'],
},
columns: [{
xtype: 'gridcolumn',
dataIndex: 'dummy',
editor: {
xtype: 'textfield'
},
renderer: function (value, metaData, record, row, columnIndex, store, gridView) {
return record.get("text");
}
}],
plugins: [{
ptype: 'cellediting',
listeners: {
beforeedit: function (editor, editEvent, options) {
editEvent.value = editEvent.record.get('text');
}
}
}]
}]
});


me.callParent(arguments);
}


});

Ext.application({
stores: [

],
views: [
'MyApp.view.MyViewport'
],
name: 'MyApp',
launch: function () {
Ext.create('MyApp.view.MyViewport');
}
});
</script>
</head>

<body></body>

</html>

ihands
1 Nov 2013, 4:55 AM
Please visit this link:

http://www.kcr.uky.edu/isaac/app.html

It fails every time for me with IE, FF, Chrome, and Safari.

Gary Schlosberg
1 Nov 2013, 3:59 PM
In every browser I try, that link shows "Some Text", which I understand to mean the problem is not present.

ihands
1 Nov 2013, 5:54 PM
I see the confusion now, from my original post:

...dbl-click the "Some Text" cell and you will see the value "Dummy Value" in the text editor, it should say "Some Text".

The problem is when you enter the editor, not the initial loading of the page. Do you see that issue ?

Gary Schlosberg
2 Nov 2013, 6:01 AM
I'm terribly sorry for missing the 'double click' part of your instructions. I see this issue now for sure, and I'd say we need to fix that. I'll move this over to Bugs and file it. Thanks for your impressive patience.

Gary Schlosberg
2 Nov 2013, 6:03 AM
Thanks for the report! I have opened a bug in our bug tracker.