RadComboBox Closing on page load and onclik of another control click

2 posts, 0 answers
  1. Mugdha Aditya
    Mugdha Aditya avatar
    71 posts
    Member since:
    Mar 2010

    Posted 28 Oct 2010 Link to this post

    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>

  2. Cori
    Cori avatar
    562 posts
    Member since:
    Jul 2010

    Posted 28 Oct 2010 Link to this post

    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.
Back to Top