We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Menu element on the right of the menu

Greetings. I have the following requirement: add a menu element to the syncfusion MVC menu so that this element is docked to the right of the menu (while all the others are normally docked on the left). Is it possible to met this requirement without passing the whole menu as a JSON as explained in this howto? 

https://www.syncfusion.com/kb/3008/how-to-apply-url-htmlattribute-imageurl-linkattribute-for-menu-items

At the moment the menu is created directly in the _layout.cshtml file with the following razor syntax:

@Html.EJ().Menu("mainMenu").Items(items => {

                            items.Add().Url(Url.Action("Index", "Home")).Text("Home").Children(child =>
                                {                                  
                                        child.Add().Url(Url.Action("LogOff", "Account")).Text("Log Off");                                                                 
                                        child.Add().Url(Url.Action("LogOn", "Account")).Text("Log On");
                                    
                                });
                            items.Add().Url(Url.Action("Index", "ChiamataManutenzione")).Text("Apri chiamata");
                            items.Add().Url(Url.Action("Index", "ListaOdM")).Text("Lista OdM");
                            items.Add().Url("#").Text("Anagrafiche").Children(child =>
                            {
                                child.Add().Url(Url.Action("Index", "AnagraficaTipologiaManutenzione")).Text("Tipologie interventi");
                                    
                                child.Add().Url(Url.Action("Index", "AnagraficaCapannoni")).Text("Capannoni");
                                child.Add().Url(Url.Action("Index", "AnagraficaMacchine")).Text("Macchine");
                            });
                   }).EnableSeparator(false)



1 Reply

GS Gobalakrishnan S Syncfusion Team November 16, 2015 04:19 PM UTC

Hi Carlo,

Thanks for contacting Syncfusion support.

Yes we can achieve your requirement, without passing the menu as JSON. We can use the “insert” method in menu to add the menu items dynamically from client side. Please refer the following code,


<script>

    function onsubmitClick() {

        //Object for menu item created

        var obj = $("#mainMenu").ejMenu("instance");

        //Use "insert" method to add the menu items dyncamically

        obj.insert([{ id: 19, text: "Group A", htmlAttribute: { "class": "myclass" }}]);

    }

</script>



      <style type="text/css" class="cssStyles">

        .myclass{

            float:right;

        }

      </style>


We have attached a sample for your reference, please check it.

Samplelocation http://www.syncfusion.com/downloads/support/forum/121137/ze/SyncfusionMvcApplication1-872460121

Regards,

Gobalakrishnan S


Loader.
Up arrow icon