I have disabled Add and Delete always .. But after postback of the page . The options are automatically enabled on rightclick
This is my code :
function detailInitKendoCostGrid(e) {
if (e.data.Id > 0) {
var ds = new kendo.data.DataSource({
schema: {
id: "jobCodeID",
data: "d",
total: "d.length",
model: {
fields: {
Cost: { type: "string" },
Total: { type: "string" },
Desc: { type: "string" },
Quantity: { type: "string" },
}
}
},
pageSize: 500,
transport: {
read: {
url: "Cost.aspx/CostPart",
contentType: "application/json; charset=utf-8",
dataType: 'JSON',
type: "POST",
complete: function (jqXhr, textStatus) {
if (textStatus === 'error') {
var message = $.parseJSON(jqXhr.responseText).Message;
ShowMessageDialog(message);
}
}
},
parameterMap: function (options, operation) {
// ////
switch (operation) {
case "read":
return JSON.stringify({
"jobcodeId": e.data.Id,
});
break;
default:
return JSON.stringify(options);
break;
}
}
}
});
$("<div style='height: 400px'/>").appendTo(e.detailCell).kendoGrid({
dataSource: ds,
columns: [
{ field: "Cost", title: "Task", width: "500px" },
{ field: "Total", title: " Part Number", width: "100px" },
{ field: "Desc", title: "Part Description", width: "100px" },
{ field: "Quantity", title: "Quantity", width: "100px" },
],
selectable: true
});
}
}
function SetContextMenuforCost()
{
var taskPartGridId = "#Kendo_CostGrid";
$("#E_ContextMenu").kendoContextMenu({
dataSource: [{ text: "Add Cost" },
{ text: "Edit Cost" },
{ text: "Delete Cost" }],
target: CostGridId,
filter: ".k-detail-row tbody tr.k-state-selected[role='row']",
open: function (e) {
showopen(e);
},
select: function (e) {
ShowGridPopup(e);
},
});
$("#E_ContextMenu").kendoMenu().data("kendoMenu").enable("li:eq(1)", true);
$("#E_ContextMenu").kendoMenu().data("kendoMenu").enable("li:eq(0)", false);
$("#E_ContextMenu").kendoMenu().data("kendoMenu").enable("li:eq(2)", false);
}
function showopen(e) {
var menu = e.sender;
if (menu != null) {
var total= e.target.childNodes[3].textContent;
if (quantity > 0) {
$("#E_ContextMenu").kendoMenu().data("kendoMenu").enable("li:eq(1)", true);
$("#E_ContextMenu").kendoMenu().data("kendoMenu").enable("li:eq(0)", false);
$("#E_ContextMenu").kendoMenu().data("kendoMenu").enable("li:eq(2)", false);
}
}
}