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

RadComboBox selection persisted on a postback after clearSelection() call

1 Answer 39 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Will Lopez
Top achievements
Rank 1
Will Lopez asked on 29 May 2013, 04:26 PM
Hello:

Here's the scenario. user defines a search via several radcomboboxes. The form is cleared, using the following javascript to clear the comboboxes selected:

function ResetComboBoxValue(ctrl, isDisable) {
    var combo = $find(ctrl);
    var input = combo.get_inputDomElement();
    if (combo != null) {
        combo._enabled = true;
        combo.trackChanges();
        combo.clearSelection();
        combo.set_emptyMessage(combo.get_emptyMessage());
        if (isDisable) {
            combo._enabled = false;
            input.readOnly = true;
        }
        combo.commitChanges();
    }
}

All that looks good until a postback is done then the previously selected values are "restored". I thought that by using the commitChanges() it would sync the client changes to the server to prevent the previous selected items from being restored. 

Thanks!

1 Answer, 1 is accepted

Sort by
0
Will Lopez
Top achievements
Rank 1
answered on 29 May 2013, 05:48 PM
A coworker came up with this. It works.

function ResetRadCbChkValue(ctrl) {
    var combo = $find(ctrl);
    if (combo != null && combo._text != "") {
        var items = combo.get_checkedItems();
        combo.clearSelection();
        var i = 0;
        while (i < items.length) {
            items[i].uncheck();
            i++;
        }
        combo.set_emptyMessage(combo.get_emptyMessage());
    }
}
Tags
ComboBox
Asked by
Will Lopez
Top achievements
Rank 1
Answers by
Will Lopez
Top achievements
Rank 1
Share this question
or