How to display html as text inside EXTJS combo box

developer747

Paste the code blow inside Sencha fiddle. Look at the item that reads ProblemElement.

Ext.define('DropDownList', {
    extend: 'Ext.form.ComboBox',
    editable: false,

    alias: 'widget.dropdownlist',
    initComponent: function() {
        this.callParent([arguments]);
    },
    onRender: function() {
        this.callParent();

    }
});


var states = Ext.create('Ext.data.Store', {
    fields: ['abbr', 'name'],
    data: [

        {
            "name": "Alabama"
        }, 
        {
            "name": "Alaska"
        }, 
        {
            "name": " <input value='ProblemElement'>"
        }
    ]
});

Ext.application({

    name: 'MyApp',
    launch: function() {


        Ext.create('Ext.form.Panel', {

            items: [{
                xtype: 'dropdownlist',
                hideLabel: false,
                title: 'ComboBox Test',
                fieldLabel: 'Choose State',
                store: states,
                displayField: 'name',
                htmlEncode: true,
                renderTo: Ext.getBody()
            }]

        });
    }
});

The problem I am facing is that the item displayed in the dropdown is being rendered as HTML. However after I select it it displays correctly as text (<input value='ProblemElement'>), the way I want it.

Greendrake

The dropdown list is actually a Boundlist, and how item text is displayed is controlled by its getInnerTpl method. You can customize the combo's dropdown with listConfig so that the inner text is passed through Ext.String.htmlEncode:

listConfig: {
    getInnerTpl: function(displayField) {
        return '{[Ext.String.htmlEncode(values.' + displayField + ')]}';
    }
}

Full example: https://fiddle.sencha.com/#fiddle/rkk

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Display combo box when checkbox is checked - Extjs

From Dev

Extjs how to add close icon to the combo box

From Dev

Extjs how to remove and undo list items from extjs combo box

From Dev

How to add a text box + combo box

From Dev

How to display bootstrap select combo box in datatable?

From Dev

How to populate the value of a Text Box based on the value in a Combo Box in a html page

From Dev

How to select an bounded combo box value and display its value into an Label Text

From Dev

How can I code a combo box to display a list in a list box based on the selection in the combo box?

From Dev

How to work with combo having images inside in extjs 4.1

From Dev

Extjs - Setvalue to numberfield inside combo

From Dev

How to multiply a combo box and a text box value in VB?

From Dev

How to display plain text in ExtJs

From Dev

ExtJS 5 html in combo inputfield

From Dev

set combo box width to auto fit it's longest field option text in ExtJS

From Dev

How to put fa-search inside a HTML input text box?

From Dev

Display Label and Progressbar into combo box

From Dev

ExtJs 3.4 : Set tool tip for combo box

From Dev

Dynamic store not loading data in combo box extjs

From Dev

ExtJs 3.4 : Set tool tip for combo box

From Dev

dynamically change the combo box store in extjs

From Dev

How to Create A Suggestion Box (Prompt Box in Javascript) Inside a Html Box With Text

From Dev

Vaadin 7 Combo Box - how to populate and dropdown when text is typed?

From Dev

How to get text from Combo box c# Wpf?

From Dev

How to insert text to QTextEdit according to combo box CurrentText?

From Dev

How can I add a value from a combo box into a text area?

From Dev

How to restrict entering of custom text to a combo box in wix

From Dev

let to right the combo box in html

From Dev

How can I display certain text from a javascript inside the html?

From Dev

Unable to display value in HTML text input box

Related Related

  1. 1

    Display combo box when checkbox is checked - Extjs

  2. 2

    Extjs how to add close icon to the combo box

  3. 3

    Extjs how to remove and undo list items from extjs combo box

  4. 4

    How to add a text box + combo box

  5. 5

    How to display bootstrap select combo box in datatable?

  6. 6

    How to populate the value of a Text Box based on the value in a Combo Box in a html page

  7. 7

    How to select an bounded combo box value and display its value into an Label Text

  8. 8

    How can I code a combo box to display a list in a list box based on the selection in the combo box?

  9. 9

    How to work with combo having images inside in extjs 4.1

  10. 10

    Extjs - Setvalue to numberfield inside combo

  11. 11

    How to multiply a combo box and a text box value in VB?

  12. 12

    How to display plain text in ExtJs

  13. 13

    ExtJS 5 html in combo inputfield

  14. 14

    set combo box width to auto fit it's longest field option text in ExtJS

  15. 15

    How to put fa-search inside a HTML input text box?

  16. 16

    Display Label and Progressbar into combo box

  17. 17

    ExtJs 3.4 : Set tool tip for combo box

  18. 18

    Dynamic store not loading data in combo box extjs

  19. 19

    ExtJs 3.4 : Set tool tip for combo box

  20. 20

    dynamically change the combo box store in extjs

  21. 21

    How to Create A Suggestion Box (Prompt Box in Javascript) Inside a Html Box With Text

  22. 22

    Vaadin 7 Combo Box - how to populate and dropdown when text is typed?

  23. 23

    How to get text from Combo box c# Wpf?

  24. 24

    How to insert text to QTextEdit according to combo box CurrentText?

  25. 25

    How can I add a value from a combo box into a text area?

  26. 26

    How to restrict entering of custom text to a combo box in wix

  27. 27

    let to right the combo box in html

  28. 28

    How can I display certain text from a javascript inside the html?

  29. 29

    Unable to display value in HTML text input box

HotTag

Archive