reymo
April 20, 2016, 11:12am
#1
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
Andrei
April 21, 2016, 8:50am
#2
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();
});
reymo
April 21, 2016, 6:41pm
#3
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.
Andrei
April 27, 2016, 2:32pm
#4
Hi
then meet code version 2.0
[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]
reymo
April 28, 2016, 9:31am
#5
Hi Andrei,
Thanks, that’s the solution!