<Grid>
$("#Grid").ejGrid({
// the datasource "window.gridData" is referred from jsondata.min.js
dataSource: window.gridData,
. . .
contextMenuSettings: { enableContextMenu: true, disableDefaultItems: true, customContextMenuItems: [{ id: 'delete', text: "Delete" }], },
//Row selected event
rowSelected: function (args) {
if (!$("#delete").find("ul").length > 0 && args.data.EmployeeID == 5) //Check the condition if employee id value is equal to 5
showSubMenuItem(args);
else
disableSubMenuItem(args);
},
contextClick: function (args) {
// Code something
},
columns: [
. . .
]
});
});
function showSubMenuItem(args) { //Here we can append the sub contextmenu items
function showSubMenuItem(args) {
//SubcontextMenu generation
var ObjUl = $("<ul id='subItems' ></ul>"); //Create a <ul> tag
var Objli = $('<li></li>'); //Create a <li> tag
var Obja = $('<a></a>'); //Create a <a> tag
Objli.addClass("e-customitem e-list"); //Add a specific class for Subcontext menu
Obja.addClass("e-menulink"); //Add a specific class for Subcontext menu
Obja.text('EmployeeID value is equal to' + " "+ args.data.EmployeeID); // Set the text for subcontext menu
Objli.append(Obja); //Append the corressponding elements
ObjUl.append(Objli); //Append the corressponding elements
$("#delete").append(ObjUl); //Append the corressponding elements
}
}
function disableSubMenuItem(args) {
if ($("#delete").find("ul").length > 0)
$("#subItems").remove();//Here we can remove the subcontext menu item which has employee id not equal to 5
}
</script> |