This is a migrated thread and some comments may be shown as answers.

Kendo Context Menu's disabled menu's are getting enabled after page postback - Asp.Net [ Web Forms ]

1 Answer 126 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Aravindan
Top achievements
Rank 1
Aravindan asked on 12 Apr 2017, 08:03 AM

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);
        }
    }
}

1 Answer, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 13 Apr 2017, 12:48 PM
Hello Aravindan,

Your code is not runnable, so I attached a sample runnable page that simulates your scenario. The code in the showopen function is commented because it is not clear where the "quantity" variable is defined and what are its expected values.
At my end selecting a row then right-clicking on it shows the Add and Delete items disabled. Above the Grid there is a button that initiates postback on click. After the postback the ContextMenu items are still disabled. Could you modify the page accordingly so that the issue is reproduced and attach it back for further review?

Regards,
Ivan Danchev
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
General Discussions
Asked by
Aravindan
Top achievements
Rank 1
Answers by
Ivan Danchev
Telerik team
Share this question
or