PDA

View Full Version : BUG: Combobox htmlEncoding; encoding diffrent in displayField then in the dropdown.



VDP
3 Aug 2012, 5:47 AM
I have an item in a dropdown '<new item>' now in the dropdown it doesn't automatically convert to htmlEncoded chars. But when selected it is htmlEncoded properly.

code:


// The data store containing the list of states
var states = Ext.create('Ext.data.Store', {
fields: ['abbr', 'name'],
data : [
{"abbr":"AL", "name":"Alabama"},
{"abbr":"AK", "name":"Alaska"},
{"abbr":"AZ", "name":"<new Item>"}
//...
]
});


// Create the combo box, attached to the states data store
Ext.create('Ext.form.ComboBox', {
fieldLabel: 'Choose State',
store: states,
queryMode: 'local',
displayField: 'name',
valueField: 'abbr',
renderTo: Ext.getBody()
});

screenshot:
37727

If I convert the value the dropdown is fine but selected value isn't!

code:


// The data store containing the list of states
var states = Ext.create('Ext.data.Store', {
fields: ['abbr', 'name'],
data : [
{"abbr":"AL", "name":"Alabama"},
{"abbr":"AK", "name":"Alaska"},
{"abbr":"AZ", "name":"<new Item>"}
//...
]
});


// Create the combo box, attached to the states data store
Ext.create('Ext.form.ComboBox', {
fieldLabel: 'Choose State',
store: states,
queryMode: 'local',
displayField: 'name',
valueField: 'abbr',
renderTo: Ext.getBody()
});

screenshot:
37728

sword-it
4 Aug 2012, 5:33 AM
Hi VDP,

Are you use charset = utf-8 in index page ?
Replace <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

with

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
Or
<meta http-equiv="content-type" content="text/html;charset=windows-1254"/>

Working Sample example - http://jsfiddle.net/cjhWB/1/

VDP
5 Aug 2012, 4:56 AM
the fix isn't to set the charset. you added spaces "< new item >" works "<new item>" doesn't because it thinks <new> is a tag and item is a propperty that's why the value needs to be htmlEncoded.



evant (http://www.sencha.com/forum/member.php?2950-evant) said:

We have a ticket already open regarding addressing html encoding across the framework, it's not just limited to this.

In the interim, use:



Ext.onReady(function() {
// The data store containing the list of states
var states = Ext.create('Ext.data.Store', {
fields: ['abbr', 'name'],
data: [{
"abbr": "AL",
"name": "Alabama"
}, {
"abbr": "AK",
"name": "Alaska"
}, {
"abbr": "AZ",
"name": "<new Item>"
}]
});


// Create the combo box, attached to the states data store
Ext.create('Ext.form.ComboBox', {
fieldLabel: 'Choose State',
store: states,
queryMode: 'local',
displayField: 'name',
valueField: 'abbr',
renderTo: Ext.getBody(),
listConfig: {
getInnerTpl: function(){
return '{name:htmlEncode}';
}
}
});
});





refrence (http://www.sencha.com/forum/showthread.php?235931-Combobox-htmlEncoding-encoding-diffrent-in-displayField-then-in-the-dropdown.)