PDA

View Full Version : Combobox - Problem with Special characters Show



ladro1987
30 Apr 2010, 8:17 AM
Hi all,
I have a problem with a special characters view into combobox.

I view, for example, ->è , &->& , ->ù , ecc ecc...

I have apply the "tpl" but non shaw characters correctly.

This is my combobox:


var sel_azienda = new Ext.form.ComboBox({
xtype:'combo',
store: store_aziende,
minChars:1,
tpl: '<tpl for="."><div class="x-combo-list-item">{rag_soc:htmlEncode}</div></tpl>',
valueField: 'id_azienda',
hiddenName: 'id_azienda',
displayField: 'rag_soc',
triggerAction: 'all',
selectOnFocus:false,
mode: 'remote',
typeAhead: true,
editable: true,
width: 200,
emptyText: 'Seleziona una tua Azienda',
forceSelection: true,
blankText:'Seleziona <b>l\'azienda</b> relativa alla convenzione',
allowBlank: false
});


I take the "<tpl>" from this question:
http://www.extjs.com/forum/showthread.php?54194-special-characters-in-MessageBox-and-combo-box-does-not-display

Help me plz!!:s:s

cnelissen
30 Apr 2010, 11:19 AM
If your page is properly encoded this shouldn't be an issue. Make sure your document is using a UTF-8 charset, ie:



<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />


Alternatively you could html encode the data before you send it to your store, which is probably the least error prone.

ladro1987
2 May 2010, 7:58 AM
Hi,
thanks for the response. :)

I have controlled the charser end it's correctly.

Now i explain better the problem:
The special characters see correctly into combobox before this is select.

After the select, for example change in &agrave; , & change in &amp;, ecc ecc..

I think that the problem stay into the htmlDecode...

tpl: '<tpl for="."><div class="x-combo-list-item">{rag_soc:htmlDecode}</div></tpl>',

I have attach a image that show the problem.

Thanks for the responce. :-)

20271
Roberto

ladro1987
3 May 2010, 4:57 AM
Now I sending at the combobox the chars converted in this method:

htmlentities($value, ENT_QUOTES, "UTF-8")

I add a 'listeners' at combobobox, that convert with htmlDecode the special chars on select.
With the special chars content into this function, there aren't problems; instead, with other chars for example "", "", ecc... don't convert this chars.
During the selection, the chars seen correctly, but, if I select the word with contain the special char, on select, transform the special letter into a question mark <?>.
This is my combobox:


var sel_azienda = new Ext.form.ComboBox({
xtype:'combo',
store: store_aziende,
minChars:1,
listeners:{
select: function(el,type){
var newDisplayValue = Ext.util.Format.htmlDecode(this.getRawValue());
this.setRawValue(newDisplayValue);
}
},
valueField: 'id_azienda',
hiddenName: 'id_azienda',
displayField: 'rag_soc',
triggerAction: 'all',
selectOnFocus:false,
mode: 'local',
typeAhead: true,
editable: true,
width: 200,
lazyRender: true,
emptyText: 'Seleziona una tua Azienda',
forceSelection: true,
blankText:'Seleziona <b>l\'azienda</b> relativa alla convenzione',
allowBlank: false
});


I precise again, that the problem there is when into the word there are char like "", "", "", ecc... .

I try to add a special char to a function htmlDecode in this mode and there aren't any results :


htmlDecode : function(value){
return !value ? value : String(value).replace(/&gt;/g, ">").replace(/&lt;/g, "<").replace(/&quot;/g, '"').replace(/"/g, '"').replace(/'/g, "'").replace(/&amp;/g, "&").replace(/&egrave/g, "");
},


How can I convert this special chars??

Help me please! :s:s

cnelissen
3 May 2010, 7:12 AM
Again, encode the characters before you send the data to your store. Your backend script can handle this as the data is pulled from a database, and then you don't have to worry about it in the front end ever again.

ladro1987
7 May 2010, 1:39 AM
Hi,
thanks for the responce...
I try to encode the characters before that send the data to the store, but don't show the special caracters.
For example... allorch -> allorch

I don't have any idea!!


I'm a novice with EXTJS... :s

Can you post some example like send data to my store plz? wouldn't like mistake...

Thank you!

Roberto.

ladro1987
11 May 2010, 12:41 AM
anyone can help me??

Animal
11 May 2010, 1:19 AM
Send you data in JSON format serialized by a good JSON library.

That way, special characters will be encoded using "\uxxxx" encoding which means that the encoding is moot. These characters are within the range were ISO-8859-1 intersects with UTF-8, so it just won't matter.

ladro1987
18 May 2010, 1:27 AM
Hi,
thanks for the cordial responce.
I've resolved the problem.

There isn't probelm in the script. I've just change the following charset:


<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> into the following new charset:


<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
I precise that i upgrade the EXTJS function of htmlDecode/htmlEncode with the new chars to be converted.
for example:


htmlDecode : function(value){
return !value ? value : String(value).replace(/&gt;/g, ">").replace(/&lt;/g, "<").replace(/&quot;/g, '"').replace(/"/g, '"').replace(/'/g, "'").replace(/&amp;/g, "&") .replace(/&egrave/g, "");
}, and the htmlEncode in the following mode:


htmlEncode : function(value){
return !value ? value : String(value).replace(/&/g, "&amp;").replace(/>/g, "&gt;").replace(/</g, "&lt;").replace(/"/g, "&quot;").replace(//g, "&egrave;");
},
I hope to be helpful with this thread.

Roberto.