Hi,
We have a scenario whereby we have developed a user control that contains 3 related RadCombBox controls. Each of the comboboxes is loaded via a webservice call with the the parameter used for the second coming from the selected value of the first and the parameter used for the third coming from the selected value for the second.
Server side, setting this up is no problem, and when the SelectedItemChanged even is fired we do a postback and reset the depedent box(es) web parameters. However, when the user deletes the selected value from the first, say, there's no need to do a postback we just want to clear the items in the second and third and clear the web parameters.
Here's our code
onClassificationChanged: function (eventArgs) {
ClearRADCombo(this._nameComboID);
ClearRADCombo(this._valueComboID);
var classificationCombo = this.get_classificationCombo();
var value = classificationCombo.get_value();
if (value === undefined || value === "") {
this.resetParameter(this._nameComboID, "ClassificationID");
this.resetParameter(this._valueComboID, "NameID");
}
},
resetParameter: function (comboID, parameterName) {
var combo = $find(comboID);
var paramAttrib = combo.get_attributes().getAttribute("WebServiceParameters");
if (paramAttrib) {
var parameters = JSON.parse(paramAttrib);
for (var i = 0; i < parameters.length; i++) {
if (parameters[i].Name === parameterName) {
parameters[i].Value = "";
break;
}
}
var str = JSON.stringify(parameters);
combo.get_attributes().setAttribute("WebServiceParameters", str);
combo.get_element().setAttribute("WebServiceParameters", str);
}
},
function ClearRADCombo(controlId) {
var ctrl = window.$find(controlId);
if (ctrl) {
ctrl.clearItems();
ResetRADCombo(controlId);
}
}
function ResetRADCombo(controlId) {
var ctrl = window.$find(controlId);
if (ctrl) {
ctrl.clearSelection();
ResetValidators(controlId);
}
}
Note, the three combos are 'Classification', 'Name' and 'Value' (with Name dependent on 'Classification' and 'Value' dependent on name).
The onClassificationChanged function is linked with the 'OnBlur' event.
The problem is that sometimes the combo boxes successully clear the items but sometimes they don't (even though when debugging we can see that the code is still being hit).
Anybody know why the items wouldn't always clear?