`
编程足球
  • 浏览: 250792 次
  • 性别: Icon_minigender_1
  • 来自: 福州
社区版块
存档分类
最新评论

Ext Combo 添加空值并且显示出来

    博客分类:
  • Ext
 
阅读更多
1、最简单的方案是在后台从数据库中查询了Combobox数据时,在返回的结果中构造一个包含空值 的项;
2、第二种方案是在加载Storer后,在回调函数中手动往Store中加入一条数据记录。
roleAll.load({
	callback:function(records, options, success){
		//插入一条空记录			
		var e = new configRoleRecord({
		  	id : "",
		   	roleEn:"",
		   	roleCn: ""
		});
		this.insert(0, e);
	}
});	


但是上面的操作还是没办法正常的显示这个空值,还要进行下一步操作
重载combox的initList方法,使得可以正常显示空格
/**
 * 空选项不能正常显示
 * 进行修正
 */
Ext.override(Ext.form.ComboBox, 
{
	initList: (
		function(){
			if(!this.tpl) {
				this.tpl = new Ext.XTemplate('<tpl for="."><div class="x-combo-list-item">{', 
								this.displayField , ':this.blank}</div></tpl>', 
								{blank: function(value){return value==='' ? '&nbsp' : value;}
				});
			}
	}).createSequence(Ext.form.ComboBox.prototype.initList)
});
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics