@Html.EJS().Grid("parentgrid").QueryCellInfo("QueryCellInfo").DataSource((IEnumerable<object>)ViewBag.Employees).Columns(col =>
{
col.Field("EmployeeID").HeaderText("Employee ID").Width("125").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
col.Field("Name").HeaderText("Name").Width("125").Add();
col.Field("Title").HeaderText("Title").Width("180").Add();
col.Field("City").HeaderText("City").Width("135").Add();
col.HeaderText("Actions").Width("135").Template("#template").Add();
}).AllowSorting().Render()
<script id="template" type="text/x-template">
<ul class="menu"></ul>
</script> |
<script>
function QueryCellInfo(args) {
if (args.column.headerText === "Actions") {
// Get the ul element inside the cell
// you can set unique id for the menu ul element
var menuEle = args.cell.querySelector('.menu');
// Menu items
var menuItems = [
{
iconCss: 'e-icons MT_Menu',
items: [
{ text: 'Cut', iconCss: 'e-icons Cut' },
{ text: 'Copy', iconCss: 'e-icons Copy' },
{ text: 'Paste', iconCss: 'e-icons Paste' },
]
}
];
// Initialize Menu component.
var menuObj = new ej.navigations.Menu({ items: menuItems });
menuObj.appendTo(menuEle);
}
}
</script> |
<style>
.MT_Menu::before {
content: '\e984';
}
.Cut::before {
content: '\e604';
}
.Copy::before {
content: '\e60d';
}
.Paste::before {
content: '\e601';
}
// Removes the caret icon displayed in the menu
.e-menu-wrapper ul .e-menu-item .e-caret::before {
content: '' !important;
}
.e-menu-wrapper ul.e-menu {
width: 44px;
}
</style> |
<style>
.e-menu-parent.e-ul {
height: 120px;
width: 100px;
}
</style> |
// Adjusting position of the menu element
.e-menu-wrapper {
margin-left: 11px;
}
// Modifying the width of the parent menu item
.e-menu-wrapper ul.e-menu {
width: 20px;
}
// Adjusting the position of the caret icon rendered inside the menu
.e-menu-wrapper ul.e-menu .e-menu-item {
padding-left: 3px;
padding-right: 3px;
width: 20px;
} |