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
close icon

how I add a menu in the grid toolbar

I would like to add a menu in the toolbar which is in the grid but it doesn´t work, thanks for the help

Attachment: toolbar_grid_284a8cc2.zip

1 Reply

TS Thavasianand Sankaranarayanan Syncfusion Team November 22, 2019 01:10 PM UTC

Hi Ricardo,  

Greetings from Syncfusion support 

We suggest you to follow the below steps. Here we have used the created event to render the Menu in grid toolbar. Please follow the code snippet and sample for more reference. 

Index.cshtml 

@{ 
    List<object> toolbarItems = new List<object>(); 
    toolbarItems.Add(new { text = "Menu", template = "#menuitem" }); 
} 
 
<div id="menuitem">                                                               // div element is created 
    <ul class="menu" id="tool_menu"></ul> 
</div> 
 
 
@Html.EJS().Grid("grid").DataSource((IEnumerable<object>)ViewBag.DataSource). 
ShowColumnChooser(true).AllowPaging(true). 
        …  
}).Created("created").Toolbar(toolbarItems).AllowPaging().Render() 
<script> 
 
    function created() { 
        var menuItems = [ 
            { 
                text: 'Items', 
                iconCss: 'e-icons MT_menu1', 
                items: [ 
                    { text: 'Item 1' },                           // items in the Menu  
                    { text: 'Item 2' }, 
                    { text: 'Item 3' }, 
                ] 
            } 
        ]; 
 
        var menuObj = new ej.navigations.Menu({ items: menuItems, select: onMenuSelect });  //Menu is created 
        menuObj.appendTo("#tool_menu");                                         // Menu is append to created div element 
    } 
    function onMenuSelect(args) { 
        // Triggers on selecting menu item 
    } 
</script> 
 



Please get back to us if you need further assistance 

Regards 
Thavasianand S. 


Loader.
Live Chat Icon For mobile
Up arrow icon