View Full Version : [2.2] ComboBox does not display HTML chars
Northrog
22 Aug 2008, 5:01 AM
Hi,
I just recognized a bug:
A combo box does display HTML-chars like ü or á in the list, but it does not display them in the "selected"-field.
So a list element like that: 3 St
Hello Northog,
you have to set a own tpl as described here (http://extjs.com/forum/showthread.php?t=41956).
t34
jay@moduscreate.com
22 Aug 2008, 5:25 AM
I think it's because normal input boxes maybe don't do it?
Northrog
22 Aug 2008, 5:36 AM
if you mean it like this:
this.defComboBox=new Ext.form.ComboBox({
typeAhead: true,
lazyRender:true,
listClass: 'x-combo-list-small',
triggerAction: 'all',
editable: false,
readonly: true,
displayField: 'text',
valueField: 'value',
store: eproc_obj.umpackidComboStore,
tpl :'<tpl for="."><div class="list-item">{' + this.displayField + ':htmlEncode}</div></tpl>'
}),
I get only 'undefined' in the text.
if i make it like this:
this.defComboBox=new Ext.form.ComboBox({
typeAhead: true,
lazyRender:true,
listClass: 'x-combo-list-small',
triggerAction: 'all',
editable: false,
readonly: true,
displayField: 'text',
valueField: 'value',
store: eproc_obj.umpackidComboStore,
tpl :'<tpl for="."><div class="list-item">{text:htmlEncode}</div></tpl>'
Nothing happens at all, except of the list-items no longer being clickable.
How to use it properly?
@jgarcia: Of course this is the reason, but you still have to have an option which renders the value correctly. This option seems to be given by the tpl-property (thanks).
jay@moduscreate.com
22 Aug 2008, 5:38 AM
template is just for the LIST, not for the input box
Northrog
22 Aug 2008, 5:46 AM
Hm but the way i use it (the 2nd code snippet) it is applied to the list, if i am doing something wrong (and i AM probably doing something wrong), please tell me how to correctly apply it to the list.
jay@moduscreate.com
22 Aug 2008, 5:50 AM
A combo box does display HTML-chars like ü or á in the list, but it does not display them in the "selected"-field.
This is not a bug :)
http://tdg-i.com/img/screencasts/2008-08-22_0949.png
Northrog
22 Aug 2008, 6:03 AM
I do know that it is not a bug but a normal HTMl input field displays chars like "
jay@moduscreate.com
22 Aug 2008, 6:05 AM
can you post some of your data so we can replicate the issue?
Northrog
22 Aug 2008, 6:09 AM
Of course...here are some snippets:
this.defComboBox=new Ext.form.ComboBox({
typeAhead: true,
lazyRender:true,
listClass: 'x-combo-list-small',
triggerAction: 'all',
editable: false,
readonly: true,
displayField: 'text',
valueField: 'value',
store: eproc_obj.umpackidComboStore,
tpl :'<tpl for="."><div class="x-combo-list-item">{text:htmlEncode}</div></tpl>'
}),
the store:
this.umpackidComboStore=new Ext.data.JsonStore({
url: EPROC_DB_URL,
root: 'items',
baseParams: {what: 'cb'},
fields: ['value','text']
}),
and a sample server response:
[code]
{ items: [value: '1', text: 'Ein St
Animal
22 Aug 2008, 11:53 PM
I think the problem is in the underlying JsonStore.
You need to check the encoding in the server response. Ajax uses UTF-8, so your server should encode its Unicode characters into a byte stream using UTF-8 encoding.
If it's falling back to Latin (ISO 8859-1), you can be sure of data arriving correctly by using Javascript escapes:
{ items: [value: '1', text: 'Ein St\u00fcck'] }
Powered by vBulletin® Version 4.1.5 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.