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

[Solved] How to add a separator between menu items?

2 Answers 264 Views
Menu
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Wicky
Top achievements
Rank 1
Wicky asked on 25 Oct 2011, 04:28 AM
Hi,

I'm trying to add a separator in MVC menu:
Menu
    Child Item 1
    Child Item 2
    separator
    Child Item 3
    Child Item 4
But I couldn't find a property named "IsSeparator".
After some research, I found this way:
item.Add().Text("<hr/>").Encoded(false);
But the it doesn't look like a standard menu separator line.

I would like to ask what's the correct way to add a separator in MVC menu items?

Thanks
Wicky

2 Answers, 1 is accepted

Sort by
0
Wicky
Top achievements
Rank 1
answered on 25 Oct 2011, 06:13 AM
Hi,

After some tries, I have this function, which can add separator looks good:
public static MenuItemBuilder AddSeparator(this MenuItemFactory mif)
 {
           return mif.Add()                
              .Encoded(false)
              .Enabled(false)
              .Text("<hr />")
              .LinkHtmlAttributes(new { style = "padding:0px; margin:0px;" });            
}

If there is another better way, please let me know.

Thanks
Wicky
0
Jerry
Top achievements
Rank 1
answered on 22 Nov 2011, 05:27 PM
This - the inability to add a menu separator with little effort - is an oversight by Telerik which needs to be remedied.  The solution listed here messes up the right and left edges of the menu item.  It looks unprofessional and requires too much coding by the developer.  It should be as simple as having a .Separator option with menu.Add().
Tags
Menu
Asked by
Wicky
Top achievements
Rank 1
Answers by
Wicky
Top achievements
Rank 1
Jerry
Top achievements
Rank 1
Share this question
or