PDA

View Full Version : [FIXED-195][3.0.0] ComboBox grid editor shows valueField instead of displayField



ExtMore
27 Aug 2009, 1:29 AM
Ext version tested:

Ext 3.0 rev 0


Adapter used:

ext


css used:

only default ext-all.css



Browser versions tested against:

Chrome 2.0.172.43
IE8
FF3.5.2 (firebug 1.4.2 installed)
Safari 4.0.3


Operating System:

Vista


Description:

I have a ComboBox in an EditorGridPanel. The combo is configured with valueField and DisplayField, as well as typeAhead and selectOnFocus. There is also a renderer as described in the API docs.
When I select a value from the combo with the keyboard and then click to edit the combo in another row, then this second combo shows the valueField instead of the displayField.
If I instead select with the mouse from the first combo, then the second combo shows the displayField correctly.
I am making a grid for effective data entry, and so keyboard-only operation is essential.



Test Case:



<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title id='title'>Combo/Grid problem</title>

<!-- ** CSS ** -->
<!-- base library -->
<link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" />

<!-- overrides to base library -->


<!-- ** Javascript ** -->
<!-- base library -->
<script type="text/javascript" src="../../adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="../../ext-all-debug.js"></script>


<!-- overrides to base library -->

<!-- extensions -->

<!-- page specific -->

<script type="text/javascript">
Ext.BLANK_IMAGE_URL = '../../resources/images/default/s.gif';

var comboStore = new Ext.data.ArrayStore({
fields: [{name:'id', type: 'int'}, {name: 'color', type: 'string'}],
data: [[1, 'Red'], [2, 'Green'], [3, 'Blue'], [4, 'Yellow']]
});

var gridStore = new Ext.data.ArrayStore({
fields: [{name: 'text', type: 'string'}, {name: 'color', type: 'int'}],
data: [['ASDFSF', 1],['QWERTY', 3],['ZXCVBN', 2]]
});

var colorCombo = new Ext.form.ComboBox({
store: comboStore,
mode: 'local',
typeAhead: true,
selectOnFocus:true,
triggerAction: 'all',
valueField: 'id',
displayField: 'color'
});

Ext.util.Format.comboRenderer = function(combo){
return function(value){
var record = combo.findRecord(combo.valueField, value);
var res = (record ? record.get(combo.displayField) : ("hmm, not found:" + value));
return res;
}
}

Ext.onReady(function(){
new Ext.Viewport({
layout: "fit",
items: [
{
xtype: "editorgrid", store: gridStore, clicksToEdit: 1,
columns: [
{
header: 'Text', dataIndex: 'text',
editor: {xtype: 'textfield', selectOnFocus: true}
},
{
header: 'Color', dataIndex: 'color',
editor: colorCombo,
renderer: Ext.util.Format.comboRenderer(colorCombo)
}
]
}
]
});
}); //end onReady
</script>

</head>
<body>
</body>
</html>
Steps to reproduce the problem:

Click once in the 'Color' column of row 1, and hit 'G' to complete 'Green', then hit <ENTER>.
Now click once in the 'Color' column of row 2.


The result that was expected:

The 'Color' column of row 2 should display 'Blue'


The result that occurs instead:

The 'Color' column of row 2 displays '3', which is the valueField (id field of combiStore)


Debugging already done:

none


Possible fix:

not provided

mystix
27 Aug 2009, 1:45 AM
i can confirm the issue using latest 3.x from SVN.

no issues when using the latest 2.x from SVN.

evant
27 Aug 2009, 1:47 AM
I think it may be because the store is still filtered when the value is set.

Condor
27 Aug 2009, 2:29 AM
In that case it's a duplicate of this Ext 2.1 bugreport (http://www.extjs.com/forum/showthread.php?t=39546).

ps. I don't agree with the solution (e.g. the filter shouldn't be cleared when using triggerAction:'all' with a user-set filter).
IMHO findRecord should look through the snapshot instead of the data.

mystix
27 Aug 2009, 2:59 AM
In that case it's a duplicate of this Ext 2.1 bugreport (http://www.extjs.com/forum/showthread.php?t=39546).

ps. I don't agree with the solution (e.g. the filter shouldn't be cleared when using triggerAction:'all' with a user-set filter).
IMHO findRecord should look through the snapshot instead of the data.

eh? but i tested it against 2.x SVN and couldn't replicate the issue :-/

ExtMore
27 Aug 2009, 3:14 AM
In that case it's a duplicate of this Ext 2.1 bugreport (http://www.extjs.com/forum/showthread.php?t=39546).
[...]

Ahh, interesting read! I admittedly only searched the 3.x forums. :)

Condor
27 Aug 2009, 3:40 AM
eh? but i tested it against 2.x SVN and couldn't replicate the issue :-/

You must have tested incorrectly. I tried the testcase above with 2.x SVN (after replacing ArrayStore with SimpleStore) and it also fails.

ExtMore
27 Aug 2009, 4:29 AM
@mystix: When testing on 2.x, maybe you selected a color in the first combo with the mouse? Oddly enough, the store is not filtered in that case..

mystix
27 Aug 2009, 4:29 AM
You must have tested incorrectly. I tried the testcase above with 2.x SVN (after replacing ArrayStore with SimpleStore) and it also fails.

weird... now i'm able to replicate the problem on my home rig using 2.x HEAD. :-?

evant
27 Aug 2009, 11:29 PM
Fix applied to svn in rev #5232 for patch release 3.1.

ExtMore
28 Aug 2009, 12:05 AM
Fix applied to svn in rev #5232 for patch release 3.1.

Great! Thanks! :)

nosferatum
16 Aug 2010, 7:00 AM
Exactly same problem with Ext version 3.2.0.

Just copied the sample from:
http://www.sencha.com/learn/w/index.php?title=Tutorial:Grid_PHP_SQL_Part4

(using ComboBox selecting value in EditorGridPanel).

After selecting value of the field and focusing other cell in the grid, the field displays 'valueField' of SimpleStore instead of 'displayField'. It is existing, correct value for 'valueField', when same cell is focused again, correct value is chosen in combobox.