OnChange event filtering combo

Hi,

We are using a combo with filter option “between”. We want to clear the text in the combo when the user clicks it to start filtering. When we call the setComboText(“”) on the onOpen event, the combo value is also changed and the onChange event is called with an empty combo value (which does not exist).

         resCombo = dhtmlXComboFromSelect(frmLogin.intResID);
	 resCombo.enableFilteringMode("between");
	 resCombo.attachEvent("onChange", function(value, text){
				intResID_onchange(false);
			});	

	 resCombo.attachEvent("onOpen", function(){
		 resCombo.setComboText("");
	 });

This approach worked in a previous version of DHTMLX.
Any solutions to clear the combo when start using the filter?

Best regards,
Remy

Hi

add once after dhtmlx.js loaded:

[code]dhtmlXCombo.prototype.clearInput = function() {

if (this.conf.last_hover != null) {
	this.t[this.conf.last_hover].obj.setSelected(this.t[this.conf.last_hover].item, false);
	this.conf.last_hover = null;
}

this.base.firstChild.value = "";

if (this.conf.f_mode != false) {
	this._filterOpts(true);
}

this._updateTopImage(null);
this._confirmSelect("script", false);

this.conf.last_text = this.base.firstChild.value = "";
this.conf.f_server_last = this.base.firstChild.value.toLowerCase();

};[/code]

then your onOpen callback should be like this

myCombo.attachEvent("onOpen", function(){ myCombo.clearInput(); });

Hi Andrei,

Thanks for your support, but your solution doesn’t solve the problem.
The “onChange” event is still called after the clearinput method has been called.

Hi

then meet code version 2.0 :slight_smile:

[code]dhtmlXCombo.prototype.clearInput = function() {

var f = this.callEvent;
this.callEvent = function(){return true;};

if (this.conf.last_hover != null) {
	this.t[this.conf.last_hover].obj.setSelected(this.t[this.conf.last_hover].item, false);
	this.conf.last_hover = null;
}

this.base.firstChild.value = "";

if (this.conf.f_mode != false) {
	this._filterOpts(true);
}

this._updateTopImage(null);
this._confirmSelect("script", false);

this.conf.last_text = this.base.firstChild.value = "";
this.conf.f_server_last = this.base.firstChild.value.toLowerCase();

this.callEvent = f;
f = null;

};[/code]

Hi Andrei,

Thanks, that’s the solution!