This is a migrated thread and some comments may be shown as answers.

Cascade related combox > client side clearitems problem

1 Answer 36 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Stephen
Top achievements
Rank 1
Stephen asked on 29 Mar 2017, 11:21 AM

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?

 

1 Answer, 1 is accepted

Sort by
0
Peter Milchev
Telerik team
answered on 03 Apr 2017, 10:37 AM
Hello Stephen,

As the provided code snippets were insufficient for us to create a runnable project and recreate the issue, we have prepared a sample project implementing Cascading ComboBoxes with WebService binding. To run the project you should add the Telerik assemblies in the Bin folder. 

Would you please modify the attached project so that it represents better your implementation, demonstrates the problem and send it back to us in an official support ticket? Thus, we would be able to investigate locally your exact scenario and help you more efficiently. 

Once we have a closure in the support thread we can share the solution here for convenience and better visibility from the community. 

Regards,
Peter Milchev
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
ComboBox
Asked by
Stephen
Top achievements
Rank 1
Answers by
Peter Milchev
Telerik team
Share this question
or