当前位置: 代码迷 >> Web前端 >> 扩张combo
  详细解决方案

扩张combo

热度:132   发布时间:2012-10-27 10:42:26.0
扩展combo

在实际项目使用中为了方便combo的使用,扩展了下combo

Ext.ns("Miracle.form")
Miracle.form.ComboBox=Ext.extend(Ext.form.ComboBox,{
	typeAhead : true,
	mode : 'remote',
	forceSelection : true,
	triggerAction : 'all',
	emptyText : '',
	selectOnFocus : true,
	displayField : 'name',
	valueField : 'code',
	hideTrigger : false,
	queryDelay : 500,
	url:'',
	idProperty:'code',
	fields:['code', 'name'],
	getStore :function(){
		this.store=new Ext.data.JsonStore({
			idProperty : this.idProperty,
			url : this.url,
			fields : this.fields
		})
	},
    constructor : function(config) {
    	Ext.apply(this,config);
    	if(!this.store){
    		this.getStore();
    	}
    	Miracle.form.ComboBox.superclass.constructor.call(this);
    }
})
Ext.reg("miraclecombox",Miracle.form.ComboBox);

?

使用时

new Miracle.form.ComboBox({
???? ??url :'你的URL',
??fieldLabel : 'label',
??hiddenName : 'name'
?})

?