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

Dropdown closing even after set_cancel(true)

1 Answer 31 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Joseph
Top achievements
Rank 1
Joseph asked on 21 Sep 2013, 07:59 AM
I added a RadCombobox to my page and wrote code to disable closing of the dropdown based on some condition. The issue is that the drop down is getting closed immediately after selecting an item. The 'Checkboxes' are enabled and after checking two items only the drop down should close. I have added args.set_cancel(true) in the OnClientDropDownClosing event which seems not working. Later I removed all the business logic inside that event and wrote args.set_cancel(true) and the same result is happening. So I guess the issue is not related to the logic I implemented.

Any input?
Joseph

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 21 Sep 2013, 08:52 AM
Hi Joseph,

I am not able to replicate the issue. For me args.set_cancel(true) is working properly. Please have a look at the following code that I have tried which works fine at my end.

ASPX:
<telerik:RadComboBox ID="RadComboBox1" runat="server" CheckBoxes="true" OnClientDropDownClosing="OnClientDropDownClosing1">
    <Items>
        <telerik:RadComboBoxItem Text="Item1" runat="server" />
        <telerik:RadComboBoxItem Text="Item2" runat="server" />
        <telerik:RadComboBoxItem Text="Item3" runat="server" />
    </Items>
</telerik:RadComboBox>

JavaScript:
<script type="text/javascript">
    function OnClientDropDownClosing1(sender, args) {
        var count = sender.get_checkedItems().length; // count of checked items
        if (count != 2) {
            alert("Select 2 items");
            args.set_cancel(true);
        }
    }
</script>

Thanks,
Shinu.
Tags
ComboBox
Asked by
Joseph
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Share this question
or