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