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

RadComboBox Closing on page load and onclik of another control click

1 Answer 116 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Mugdha Aditya
Top achievements
Rank 1
Mugdha Aditya asked on 28 Oct 2010, 08:01 AM

I have RadComboBox on my page for multiple item selection.
its working fine.
but when i go to page 1st time..it will open tht radcombobox automatically.
After cliking on another button also it automatically open.
i want to supress tht on clik on any other control , it should open when user click on that RadComboBox

can any onw help??

my code is as followes


<

 

 

telerik:RadComboBox ID="rdCombIssueTypeID" runat="server" HighlightTemplatedItems="True" AllowCustomText="True" Width="190px" TabIndex="0" OpenDropDownOnLoad="true" OnClientSelectedIndexChanging="OnClientSelectedIndexChanging"

 

 

 

 

CloseDropDownOnBlur="true"

 

 

 

OnClientDropDownOpening="OnClientDropDownOpening"

 

 

 

 

OnClientDropDownClosing="OnClientDropDownClosing"

 

 

 

OnClientBlur="OnClientBlur">

 

 

 

<HeaderTemplate>

 

 

 

<table cellspacing="0" cellpadding="0" border="0">

 

 

 

<tr>

 

 

 

<td>

 

 

 

<asp:CheckBox runat="server" ID="chkAll" Enabled="true" onclick="onchkStatusAllClick(this)" />

 

 

 

</td>

 

 

 

<td style="width: 100px;"> All</td>

 

 

 

</tr>

 

 

 

</table>

 

 

 

</HeaderTemplate>

 

 

 

<ItemTemplate>

 

 

 

<div onclick="StopPropagation(event)">

 

 

 

<asp:CheckBox runat="server" ID="chk1" onclick="onCheckBoxClickRadCboCourseStatus(this)" />

 

 

 

<asp:Label runat="server" ID="Label1" AssociatedControlID="chk1">

 

 

<%

 

# Eval("IssueType")%>

 

 

 

 

</asp:Label>

 

 

 

</div>

 

 

 

</ItemTemplate>

 

 

</telerik:RadComboBox>

 <script type="text/javascript" language="javascript">

        function onchkStatusAllClick(parentChk) {
            var combo =  $find("<%= rdCombIssueTypeID.ClientID %>");;
            var items = combo.get_items();
            var text = "";
            var values = "";

            //enumerate all items
            for (var i = 0; i < items.get_count(); i++) {
                var item = items.getItem(i);
                //get the checkbox element of the current item
                var chk1 = $get(combo.get_id() + "_i" + i + "_chk1");

                if (parentChk.checked) {
                    chk1.checked = true;
                    text += item.get_text() + ",";
                    values += item.get_value() + ",";
                }
                else {
                    chk1.checked = false;
                }

            }

            text = removeLastComma(text);
            values = removeLastComma(values);

            if (parentChk.checked) {
                combo.set_text("All Selected");

            }
            else {
                combo.set_text("");
            }

        }

        function onCheckBoxClickRadCboCourseStatus(chk) {

            var combo = $find("<%= rdCombIssueTypeID.ClientID %>");
            //holds the text of all checked items
            var text = "";
            //holds the values of all checked items
            var values = "";
            //get the collection of all items
            var items = combo.get_items();
            //enumerate all items
            var count = 0;
            for (var i = 0; i < items.get_count(); i++) {
                var item = items.getItem(i);
                //get the checkbox element of the current item
                var chk1 = $get(combo.get_id() + "_i" + i + "_chk1");
                if (chk1.checked) {
                    text += item.get_text() + ",";
                    values += item.get_value() + ",";
                    count += 1;
                }
            }
            if (count == 1) {
                text = removeLastComma(text);
                values = removeLastComma(values);
            }
            if (count == items.get_count())
            {
                text = "All Status";
                //chkAll
                var chkHeader = $get(combo.get_id() + "_Header" + "_chkAll");
                chkHeader.checked = true;
            }
            if (count > 1 && count != items.get_count()) {
                var chkHeader = $get(combo.get_id() + "_Header" + "_chkAll");
                chkHeader.checked = false;
            }
            if (count == 0) {
                text = "No selection";
            }
            if (text.length > 0) {
                combo.set_text(text);
            }
            else {

                combo.set_text("");

            }
        }

        var supressDropDownClosing = false;

        function StopPropagation(e) {
            //cancel bubbling
            e.cancelBubble = true;
            if (e.stopPropagation) {
                e.stopPropagation();
            }
        }
        function removeLastComma(str) {
            return str.replace(/,$/, "");
        }

        function OnClientDropDownClosing(sender, eventArgs) {
            eventArgs.set_cancel(supressDropDownClosing);
        }

        function OnClientSelectedIndexChanging(sender, eventArgs) {
            eventArgs.set_cancel(supressDropDownClosing);
        }

        function OnClientDropDownOpening(sender, eventArgs) {
            supressDropDownClosing = true;
        }

        function OnClientBlur(sender) {
            supressDropDownClosing = false;

            sender.toggleDropDown();
        }
 

    </script>

1 Answer, 1 is accepted

Sort by
0
Cori
Top achievements
Rank 2
answered on 28 Oct 2010, 01:09 PM
Hello Mugdha,

I noticed that you have OpenDropDownOnLoad="true", which is the reason why it keeps opening when the page loads and when any other control performs a postback. Just set that to false an it should work as expected.

I hope that helps.
Tags
ComboBox
Asked by
Mugdha Aditya
Top achievements
Rank 1
Answers by
Cori
Top achievements
Rank 2
Share this question
or