PDA

View Full Version : Combobox always get value of displayField in IE



volcom721
13 Sep 2012, 4:12 AM
Dear All:
I has a problem here, i think taht maybe is a bug. I write a combobox function like Ex1.
The function is work current in FireFox and Chroom, but in IE8 the value of this combobox
will always get displayField value ( "Read Only" or "Read/Write" ).
Please some body help me. thanks:).




Ex1:
...
{ header: "Policy", dataIndex:'policy', flex: 1, sortable: true, align:'center',
renderer:function(value){
return (value.indexOf('ro') > -1 )? 'Read Only':'Read/Write';
},
editor:{
xtype:'combobox',
mode: 'local',
triggerAction: 'all',
forceSelection:true,
displayField:'label',
valueField:'policy',
store:{
xtype: 'jsonstore',
fields:[ 'label', 'policy' ],
data:[
{label: 'Read Only', policy: 'ro'},
{label: 'Read/Write', policy: 'rw'}
]
}
}//eo editor
}





thanks

mitchellsimoens
17 Sep 2012, 9:08 AM
What Ext JS 4 version? Using a combobox as an editor works no issues for me.

volcom721
19 Sep 2012, 2:46 AM
Dear mitchellsimoens:
Ext version tested:
Ext 4.1.1

Browser versions tested against:
IE 8 (Windows)

Description:
Ext.form.field.Combobox - method getValue always get displayfield value.
The other, i has use a plug-in tool Ext.i18n.Bundle( https://github.com/elmasse/Ext.i18n.Bundle ) to display label information.

Steps to reproduce the problem:
Create an form contain a Ext.form.field.Combobox.
I use a plug-tool "Ext.i18n.Bundle" to set the value of displayfield.
Select a option of combobox.
The value return by method "getValue" is displayfield value, not valuefield.


Test Case:


...
{ header: "Policy", dataIndex:'policy', flex: 1, sortable: true, align:'center',
renderer:function(value){
return (value.indexOf('ro') > -1 )?
Ext.i18n.appBundle.getMsg('Sharev.READY_ONLY'):
Ext.i18n.appBundle.getMsg('Sharev.READY_WRITE');
},
editor:{
xtype:'combobox',
mode: 'local',
triggerAction: 'all',
forceSelection:true,
displayField:'label',
valueField:'policy',
store:{
xtype: 'jsonstore',
fields:[ 'label', 'policy' ],
data:[
{label: Ext.i18n.appBundle.getMsg('Sharev.READY_ONLY'), policy: 'ro'},
{label: Ext.i18n.appBundle.getMsg('Sharev.READY_WRITE'), policy: 'rw'}
]
}
}//eo editor
}





See this URL for live test case:
none
Debugging already done:
none
Additional CSS used:
only default ext-all.css
Operating System:
WindowsXP SP3

Lunti
19 Sep 2012, 7:10 AM
The same question I answered seconds ago:


I had troubles with that, too. It's caused by writing in a combobox without selecting an item. In that case the value will be the actual inserted Text. (i. e. when having typos)

I would use the validation config in the model and make a regular expression comparison like in a numerical value:

var regex = new RegExp('^[0-9]+$');
if(this.getValue() && this.getValue().match(regex))

volcom721
20 Sep 2012, 9:48 PM
Dear lunti:
Sorry, i was review about your post( Combobox in a form posts description instead of value ), but i am so confused about that. Should i put that code you post insert to model? but the code just filter data, right?:-/
If i want to get the value from 'valuefield' that i need assigent value to 'valuefield' again, or has another why?

thank you

Lunti
23 Sep 2012, 9:48 PM
Hey volcom721,

I don't understand your problem very well. The code i gave is to prevent getting a wrong formatted value.
You can use it anywhere - if you have problems with validating for example, put it in the model validation.

In my case I had to validate it on the "select" event before I reload my store.

volcom721
25 Sep 2012, 12:30 AM
Ok, i will try again. However, i am so thanks for your help.