PDA

View Full Version : encoding html for checkbox, combobox



rkim
22 Sep 2011, 10:40 AM
What is the best way to encode html tags such as boxLabel(for checkbox) and displayField(for combobox) in extjs4 ?

I am doing template for

Ext.create("Ext.form.Combobox",
{...
tpl: new Ext.XTemplate('<tpl for="."><li class="x-boundlist-item" role="option">' + '{[this.encodeHTML(values.name)]}&nbsp;' + '</li></tpl>',
{ encodeHTML: function(val){ return MyEncodeHTMLFunction(val); }})
...
}

Do you recommend to do something similar for checkbox ?? if yes, how do we do it ??
or.. is there any recommended way from EXT ?? I don't want to change the server side to create another field.

droessner
22 Sep 2011, 1:05 PM
Not sure what else your encode function is doing, but Ext does have an htmlEncode function available.

See:
http://docs.sencha.com/ext-js/4-0/#!/api/Ext-method-htmlEncode

You could then just use Ext.htmlEncode(values.name)

rkim
22 Sep 2011, 1:12 PM
Thanks for your reply droessner. I do realize the htmlencode function from ext..
I am more wondered using template is the best option to encode display field in ext4 ? (I saw from other forum in ext3.. using template). also wondered how to do it for checkbox boxLabels.


Not sure what else your encode function is doing, but Ext does have an htmlEncode function available.

See:
http://docs.sencha.com/ext-js/4-0/#!/api/Ext-method-htmlEncode

You could then just use Ext.htmlEncode(values.name)