View Full Version : decode html entities for combo box display

30 Jun 2014, 10:20 PM
I have a combo box populated by text that has html entities in it.
The entities get decoded in the selection part, but after selection the entities show up undecoded in the box space...


... how do I persuade the displayField contents to show decoded?

I had a quick attempt to change the displayTpl to do an htmlDecode(), but that had no effect (as expected).

I can't change the source for this but am OK modifying the text before display on the client as I don't need to send the text back to the server - just the index.

Any recommendations? What's the right way to do this in Extjs - or do I just need to find a javascript equivalent to php's html_decode_entities()?

Many thanks.

1 Jul 2014, 1:19 AM
I think you should use the 'convert' function on the display field of your model. You can implement it in the model definition, or if you don't use an Ext.data.Model, you can define it directly in the Store you bind the combo to.

Ext.create('Ext.data.Store', {
fields: [
name: 'display',
convert: function(value) {
return HtmlToStringFunction(value)

1 Jul 2014, 6:55 AM
Thanks f.baron.The issue is more to do with what to use for the HtmlToStringFunction() - I was not aware of any solution for this as part of Extjs or a handy javascript function.

I was hoping that Extjs would have some way of letting the browser do the conversion/not escaping the displayed value in whatever way it does that.

I found the "he" code at the link below and this worked - I pre-decoded the strings in the store:

(https://github.com/mathiasbynens/he/Thanks)Thanks again!

28 Sep 2014, 7:36 AM
the link to github os not there anymore.can someone share the HtmlToStringFunction function?