How to add an empty item to ExtJS combobox?

前端 未结 6 685
慢半拍i
慢半拍i 2020-12-16 12:33

I want to add and empty item (display value is blank, item height is kept as normal) to an Ext.form.ComboBox. I refered 2 links below to configure my combobox, but it still

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-16 13:19

    This is how we can add a blank field in Combo box

    In java Map or any other collection put key value like this

    fuelMap.put(""," "); // we need to add " " not ""," " or null 
                              // because these will add a fine blank line in Combobox 
                              // which will be hardly noticeable.
    

    In js file, it should be like this :

    Listener for combo box

    listeners: {
        select: function (comp, record, index) {
            if (comp.getValue() === "" || comp.getValue() === " ") {
                comp.setValue(null);
            }
        }
    }
    

提交回复
热议问题