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

Keep menu item open after click

7 Answers 222 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 2
Richard asked on 18 Dec 2009, 03:31 PM
Can someone give me a hand:  I have a menu item that when clicked will be populated server-side with a sub-set of menu items.  When the user clicks the initial menu item, I'd like it to stay open after it is populated with the new items.

7 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 22 Dec 2009, 04:20 PM
Hi Richard,

Here is a sample:

<telerik:RadMenu ID="RadMenu1" Runat="server" onitemclick="RadMenu1_ItemClick">
    <Items>
        <telerik:RadMenuItem runat="server" Text="Root RadMenuItem1">
        </telerik:RadMenuItem>
    </Items>
</telerik:RadMenu>
<script type="text/javascript">
    function openFirstMenuItem() {
        var menu = $find("<%= RadMenu1.ClientID %>");
        var itemToOpen = menu.get_items().getItem(0);
        itemToOpen.open();
    }
</script>

protected void RadMenu1_ItemClick(object sender, Telerik.Web.UI.RadMenuEventArgs e)
{
    e.Item.Items.Add(new RadMenuItem("child 1"));
    e.Item.Items.Add(new RadMenuItem("child 2"));
    string script = "Sys.Application.add_load(function(){ openFirstMenuItem(); });";
    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "openmenu", script, true);
}


Greetings,
Veskoni
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Richard
Top achievements
Rank 2
answered on 22 Dec 2009, 07:47 PM
Veskoni,

Thanks for your reply and the sample code.  I tried to apply the code but found the menu didn't automatically open after I clicked the "Action" button.  I have to move my mouse back off of it then hover over it again.  By looking at your supplied code, it appears that it "should" stay open, but doesn't.

0
Genady Sergeev
Telerik team
answered on 25 Dec 2009, 12:21 PM
Hello Richard,

I have tried Veskoni's code in a sample project and it seem to work just as expected. Can you provide us with your implementation so we can see what is going wrong on your side. I have attached my test project as an attachment. Can you reproduce the problem on it?

All the best,
Genady Sergeev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
aster
Top achievements
Rank 1
answered on 28 Dec 2009, 09:32 PM
Hi Genady,

I am customizing the RadMenu control for our internal Sitefinity site, and I have a question regarding menu customization. The code with this example is partly what I am looking for, but I would like the sub menu items to stay even if the focus on them is out. They should disappear only when you click on root menu item.

I am trying to accomplish what you have on your demo site, http://demos.telerik.com/aspnet-ajax/ajax/examples/overview/defaultcs.aspx. When you click on an element the child items stay and only when you click on their parent they collapse. Could you please tell me how I can accomplish that for the RadMenu.

Thanks!
0
T. Tsonev
Telerik team
answered on 29 Dec 2009, 01:09 PM
Hi,

You can try the click-to-open mode of RadMenu. It is pretty close to what you describe. Please, see this example:

http://demos.telerik.com/aspnet-ajax/menu/examples/default/defaultcs.aspx

Check "ClickToOpen" to see this behavior.

Kind regards,
Tsvetomir Tsonev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Matteo Tognolo
Top achievements
Rank 1
answered on 22 Jul 2010, 02:42 PM
Hi,

I fill a RadMenu dinamically by List<> of objects.
I have set the navigateUrl property and I want, after the page is re-load, that the clicked item is selecetd.

Is possible associate an ID attribute to the RadMenuItem? With Attributes collection?

How can I do?

Thanks in advanced.

Matteo
0
Yana
Telerik team
answered on 28 Jul 2010, 08:43 AM
Hi Matteo Tognolo,

You should manually find the clicked menu item and selects it, this can be done in Page_Load event like this:

RadMenuItem currentItem = RadMenu1.FindItemByUrl(Request.Url.PathAndQuery);

This online example demonstrates similar approach.

Here you can read how to work Attributes collection of RadMenuItem.

Kind regards,
Yana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Menu
Asked by
Richard
Top achievements
Rank 2
Answers by
Veselin Vasilev
Telerik team
Richard
Top achievements
Rank 2
Genady Sergeev
Telerik team
aster
Top achievements
Rank 1
T. Tsonev
Telerik team
Matteo Tognolo
Top achievements
Rank 1
Yana
Telerik team
Share this question
or