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

RadMenu is hiding on postback

2 Answers 69 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Sharan
Top achievements
Rank 1
Sharan asked on 25 Nov 2013, 09:38 AM

Hi Team

I am using a RadMenu inside I have added RadMenuItems ie. CheckBox and RadCombobox.

I am opening the menu onclick of menu using the property ClickToOpen="true".

Now when I  change the RadCombox, page postbacks and bind the new values in other RadCombobox.

When postback happens the RadMenu is hiding which I DONT WANT. I want to hide the postback only on the button Go which is also a part of RadMenu.

Please can you please suggest how to prevent RadMenu to hide on Postbacks?

Below is the code I am using...
<telerik:RadMenu ID="RadMenu1" runat="server" Style="z-index: 2000" ClickToOpen="true" Visible="true"
                                        OnClientItemClosing="OnClientItemClosing">
                                        <items>
                                            <telerik:RadMenuItem Text="Card Filter">
                                                <Items>
                                                    <telerik:RadMenuItem Text="CardFilter">
                                                        <ItemTemplate>
                                                            <table>
                                                                <tr>
                                                                    <td colspan="2">
                                                                        <asp:CheckBox runat="server" ID="chkUseFleetFilter" Text="Use fleet filter for cards"
                                                                            Checked="true" AutoPostBack="true" Font-Names="Verdana" Font-Size="0.8em" OnCheckedChanged="chkUseFleetFilter_CheckedChanged" />
                                                                    </td>
                                                                    <td>
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <td>
                                                                        <asp:RadioButtonList ID="radListDateTime" Enabled="true" runat="server" Font-Names="Verdana"
                                                                            Font-Size="0.8em">
                                                                            <asp:ListItem Text="Fleet" Value="Fleet" Selected="True" />
                                                                        </asp:RadioButtonList>
                                                                    </td>
                                                                    <td>
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <td>
                                                                        <asp:Label ID="lblFleetLevel" runat="server" Width="100px" Text="Fleet Level"></asp:Label>
                                                                    </td>
                                                                    <td>
                                                                        <telerik:RadComboBox ID="ddlFleetLevel" runat="server" Width="200px" Enabled="false" OnSelectedIndexChanged="ddlFleetLevel_SelectedIndexChanged" AutoPostBack="true"
                                                                            OnClientDropDownOpening="OnClientDropDownOpening" OnClientDropDownClosed="OnClientDropDownClosed">
                                                                        </telerik:RadComboBox>
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <td>
                                                                        <asp:Label ID="lblFleetItem" runat="server" Text="Fleet Item" Visible="false"></asp:Label>
                                                                    </td>
                                                                    <td>
                                                                        <telerik:RadComboBox ID="ddlFleetItem" runat="server" Width="200px" Enabled="false" Visible="false"
                                                                            OnClientDropDownOpening="OnClientDropDownOpening" OnClientDropDownClosed="OnClientDropDownClosed">                                                                          
                                                                        </telerik:RadComboBox>
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <td>
                                                                        <asp:Label ID="lblFindCard" runat="server" Text="Find Card"></asp:Label>
                                                                    </td>
                                                                    <td>
                                                                        <telerik:RadTextBox ID="txtFindCard" runat="server" Width="200px" Enabled="false">
                                                                        </telerik:RadTextBox>
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <td>
                                                                    </td>
                                                                    <td align="left">
                                                                        <telerik:RadButton ID="btnGo" runat="server" Width="50px" Text="Go" ToolTip="Go"
                                                                            Enabled="false" />
                                                                    </td>
                                                                </tr>
                                                            </table>
                                                        </ItemTemplate>
                                                    </telerik:RadMenuItem>
                                                </Items>
                                            </telerik:RadMenuItem>
                                        </items>
                                    </telerik:RadMenu>


2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 25 Nov 2013, 10:47 AM
Hi Sharan,

The RadMenu items remain closed whenever a PostBack happens. One suggestion is that you can open the menu items by calling a client side function from the server side as shown below.

C#:
protected void ddlFleetLevel_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
{
    string menuItem = RadMenu1.SelectedItem.Text;
    string script = "function f(){openMenu('" + menuItem + "'); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true);
}

JavaScript:
<script type="text/javascript">
    function openMenu(itemText) {
        $find("RadMenu1").findItemByText(itemText).open();
    }
</script>

Thanks,
Shinu.
0
Sharan
Top achievements
Rank 1
answered on 25 Nov 2013, 11:30 AM
Thank you very much Shinu for quick reply..

Its working as expected.

Thanks
Sharan
Tags
Menu
Asked by
Sharan
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Sharan
Top achievements
Rank 1
Share this question
or