views:

344

answers:

2

With ExtJs 3.1

My Ext.form.ComboBox is built with a store in which some values are like this : "value1", "<value2>", "value3". The problem is that "<value2>" is interpreted as a HTML tag when the combobox dropdown list is displayed. And i don't want that. Any idea?

+1  A: 

Try escaping the values before binding.

Alison
I'm using Ext.util.Format.htmlEncode() but I have to alter the store for that :/
Azuriel
+2  A: 

Specify a custom template for the ComboBox list and pass the values through the HTML encoding filter:

new Ext.form.ComboBox({
    store: new Ext.data.ArrayStore({
        fields: ['field_name'],
        data: [['<item1>']]
    }),
    displayField: 'field_name',
    valueField: 'field_name',
    mode: 'local',
    tpl: '<tpl for=".">'
        +'<div class="x-combo-list-item">'
        +'{field_name:htmlEncode}'
        +'</div>'
        +'</tpl>'
});
owlness