setValue on buttonCombo without firing onSelectOption event

Hi,
Like many other users, I set the value and state of controls on the ribbon to show status for the currently selected values much like a word processor shows the font, font-size, alignment, etc.

So, having the third parameter (callback) in setItemState and setValue is huge.

However, in looking through the documentation and sources, I don’t see that third paramter (callback - true/false) for the buttonCombo. So, when I call

myRibbon.setValue(“font-size”, dropDownFontSize);

, it triggers the onSelectOption event.

Please let me know how to update the value in the buttonCombo without triggering the onSelectOption event.

Cheers,

Alex

I did more digging and seem to have come to the root of the problem…

dhtmlXCombo.prototype._confirmSelect calls onChange, but is missing a qualifier.

To fix, change

if(a==true&&c!="onInit"&&c!="onDelete"){

to

if(a==true&&c!="onInit"&&c!="onDelete"&&c!="script"){

Cheers,

Alex

Hi,

It turns out that there is a second version of the problem. To cure it, an entry also has to be made for blur. So,

if(a==true&&c!="onInit"&&c!="onDelete"){

needs to become

if(a==true&&c!="onInit"&&c!="onDelete"&&c!="script"&&c!="blur"){

Cheers,

Alex

Hi

combo is okey, 3rd param should be rendered on ribbon side. please try attached updates.
myRibbon.setValue(comboItemId, optionValue, false);
dhtmlxribbon.zip (9.57 KB)

Hi

There is similar issue also with a combo attached to a form. So when combo value/text is updated via script (e.g. in sample 08_combo.html: myForm.setItemValue(‘format’,‘WMA’); myForm.getCombo(‘format’).setComboText(‘WMA’):wink: and then clicking anywhere else in the form combo value/text is reverted back to its previous value even if free text is allowed. Is there an update to the form too?

Hi

works fine localy. please provide step-by-step guide how to reproduce?

Add the following to the end of table tag in 08_combo.html:

<tr>
  <td colspan="2">
    <input type="button" value="Set Format" onclick="myForm.setItemValue('format','WMA');myForm.getCombo('format').setComboText('WMA');"/>
  </td>
</tr>

Click the button to change the value of “Format” field and then click anywhere else in the form. The problem is that when a new value is not one of the options (like in this example) it gets changed back which I don’t want to happen. I used that form sample from dhtmlxSuite Pro 4.0.3.

I think I found one solution to my problem: last_hover property is needed to set to null so that a new value is processed correctly in _confirmSelect. If there is a better solution please let me know.

dhtmlXCombo.prototype.setComboValue = function(value) {
	// sets text in combobox, only text
	var t = this.getOption(value);
	if (t != null) {
		this.selectOption(t.index);
	} else {
		this.conf.last_hover = null;
		this.conf.last_value = value;
		this.base.childNodes[1].value = this.conf.last_value;
		this.base.childNodes[2].value = "true";
	}
};

We still can’t reproduce it locally, but if the found solution suits you, just use it.

I downloaded a fresh copy of dhtmlxSuite standard and only added that button to samples/dhtmlxForm/02_items/08_combo.html. When button is clicked the value of format field is correctly changed to WMA but when e.g. project name field is clicked afterwards format is changed back to AC3.

I will use it but I also hope that you are able to reproduce this because otherwise I would need to fix this every new version you may release.

What browser and OS do you use?

I tried this with FF33, IE11 and Chrome38 in Windows 7 64-bit and all of those worked the same way.