Ext.override(Ext.form.ComboBox, {
setValue: function(v, fireSelect) { var text = v; if (this.valueField) { var r = this.findRecord(this.valueField, v); if (r) { text = r.data[this.displayField]; if (fireSelect) { this.fireEvent('select', this, r, this.store.indexOf(r)); } } else if (Ext.isDefined(this.valueNotFoundText)) { text = this.valueNotFoundText; } } this.lastSelectionText = text; if (this.hiddenField) { this.hiddenField.value = v; } Ext.form.ComboBox.superclass.setValue.call(this, text); this.value = v; return this; } }); 擴(kuò)展的作者為Animal 調(diào)用setValue方法的同時(shí),fireEvent("select",...),觸發(fā)combo的select事件 重寫后的方法有兩個(gè)參數(shù) v:combo的valueField值,比如combo的fields: [{ name: 'CATEGORYID' }, { name: 'TITLE'}] 傳進(jìn)來(lái)的參數(shù)應(yīng)該為CATEGORYID的某一個(gè)值,而不是TITLE的某一個(gè)值。。。 fireSelect:bool類型的,即是否對(duì)setValue觸發(fā)select事件 |
|