ExtJS修復3.0奥のLovCombo(プルダウン多選枠)のBug


lovcomboが何なのか分からない場合は、http://setting.iteye.com/blog/340900を見てください.
 
 
 
3.0の中にバグがあって、選択した後に、焦点は離れる時、comboのRawValueはなくなりました…
 
次に、次のコードにナビゲートします.
//Ext.form.ComboBox  
    // private
    beforeBlur : function(){
        var val = this.getRawValue();
        if(this.forceSelection){
            if(val.length > 0 && val != this.emptyText){
               this.el.dom.value = Ext.isDefined(this.lastSelectionText) ? this.lastSelectionText : '';
                this.applyEmptyText();
            }else{
                this.clearValue();
            }
        }else{
           //      
            var rec = this.findRecord(this.displayField, val);
            if(rec){
                val = rec.get(this.valueField || this.displayField);
            }
            this.setValue(val);


        }
    },
 
 
1.まずLovComboの原理についてお話しします.
1)実はstoreにfieldを入れて、選択するかどうかをマークします.(コンフィギュレーションアイテムcheckField:'checked')
2)valueとrawValueはカンマで区切られた値です(構成項目separator:',')
 
2.だから上のvar rec=thisを見てみましょう.findRecor(this.displayField,val);得られないに違いない、recはnullで、この時valueはval、つまりrawValueに設定されていますが、次のコードで、そのsetValueはvalueを判断しているので、自然にnullです
//Ext.ux.form.LovCombo.js
setValue:function(v) {
		if(v) {
			v = '' + v;
			if(this.valueField) {
				this.store.clearFilter();
				this.store.each(function(r) {
					var checked = !(!v.match(
						 '(^|' + this.separator + ')' + RegExp.escape(r.get(this.valueField))
						+'(' + this.separator + '|$)'))
					;

					r.set(this.checkField, checked);
				}, this);
				this.value = this.getCheckedValue();
				this.setRawValue(this.getCheckedDisplay());
				if(this.hiddenField) {
					this.hiddenField.value = this.value;
				}
			}
			else {
				this.value = v;
				this.setRawValue(v);
				if(this.hiddenField) {
					this.hiddenField.value = v;
				}
			}
			if(this.el) {
				this.el.removeClass(this.emptyClass);
			}
		}
		else {
			this.clearValue();
		}
	}
 
3.修復の方法は簡単です.
1)beforeBlurの書き換え
    var combo = new Ext.ux.form.LovCombo({
      width:600,
      hideOnSelect:false,
      maxHeight:200,
      store:new Ext.data.SimpleStore({
        id:0,
        fields:['pid', 'imageName']
      }),
      triggerAction:'all',
      valueField:'pid',
      displayField:'imageName',
      mode:'local',
      beforeBlur:function(){}




    });
 
2)findRecordを書き換えて複数のrecordを返し、その上の太字部分のコードをrecordに遍歴し、valueにつづってセットする.
--これは自分で書きましょう.複雑ではありません.