Tooltips for dynamic menu items?

3 posts, 1 answers
  1. Greg Chung
    Greg Chung avatar
    48 posts
    Member since:
    Jul 2006

    Posted 20 Jun 2008 Link to this post

    I'm experimenting with the dynamic menus via web service, and they're pretty slick.  However, I can't figure out how to set the tooltips.  For a static menu, I can assign the ToolTip attrib on the RadMenuItem.  I don't know how to handle this for dynamic items.  I tried to add "ToolTip" to the attributes in the items returned by the web service.  This by itself didn't work, and I don't know how I can assign the tooltips from the item creating/populating JS events?

    If someone has an example of tooltips on the dynamic items, it would be very much appreciated!
  2. Answer
    Veselin Vasilev
    Veselin Vasilev avatar
    2992 posts

    Posted 23 Jun 2008 Link to this post

    Hi Greg Chung,

    Indeed setting the ToolTip is not currently supported out of the box. However you ca easily use the Value or Attributes property to send the tooltip (from the web service method). Then you can use the OnClientItemPopulated event to set the Tooltip for the dynamically added items.

    Here is a simple code sample:

    The WebService method:

    public RadMenuItemData[] GetMenuCategories(RadMenuItemData item, object context) 
            DataTable productCategories = GetProductCategories(item.Value); 
            List<RadMenuItemData> result = new List<RadMenuItemData>(); 
            foreach (DataRow row in productCategories.Rows) 
                RadMenuItemData itemData = new RadMenuItemData(); 
                itemData.Text = row["Title"].ToString(); 
                itemData.Value = row["CategoryId"].ToString(); 
                itemData.Attributes["TT"] = row["Title"].ToString() ; 
                if (Convert.ToInt32(row["ChildrenCount"]) > 0) 
                    itemData.ExpandMode = MenuItemExpandMode.WebService; 
            return result.ToArray(); 

    The OnClientItemPopulated event handler:

    <script type="text/javascript"
    function OnClientItemPopulatedHandler(sender, eventArgs) 
        var parent = eventArgs.get_item(); 
        var items = parent.get_items(); 
        for (var i = 0; i < items.get_count(); i++) 
            var child = items.getItem(i); 
            child.get_element().title = child.get_attributes().getAttribute("TT"); 

    I hope this helps.

    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. Greg Chung
    Greg Chung avatar
    48 posts
    Member since:
    Jul 2006

    Posted 24 Jun 2008 Link to this post

    Thanks!  That works perfectly!
Back to Top