[ExtJS] Display empty string in Ext.form.ComboBox dropdown list


/ Published in: JavaScript
Save to your folder(s)

Be default, ExtJS does not provide any special handling to display an empty string in the dropdown list of a ComboBox. In HTML, an empty DIV element as no height. So, in the dropdown list, the "empty string" option is displayed as a thin bar, almost unselectable.

This snipped force the empty string to be *rendered* as " ".


Copy this code and paste it in your HTML
  1. Ext.override(Ext.form.ComboBox, {
  2. initList: (function(){
  3. if(!this.tpl) {
  4. this.tpl = new Ext.XTemplate('<tpl for="."><div class="x-combo-list-item">{', this.displayField , ':this.blank}</div></tpl>', {
  5. blank: function(value){
  6. return value==='' ? '&nbsp' : value;
  7. }
  8. });
  9. }
  10. }).createSequence(Ext.form.ComboBox.prototype.initList)
  11. });

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.