Kendo 当网格处于编辑模式时网格阻止编辑

Kendo Grid prevent Editing while Grid Is in Edit Mode

我正在使用此 method 来防止在网格处于编辑模式时进行编辑。但我仍然发现了一些错误。 例如,首先我点击 Add New Record,然后会出现一个新行。然后我点击网格的header(参考下图)。发生了什么事创建了一行,我还没有完成编辑。如果我再次单击 Add New Record,行将重复。任何解决方案如何解决这个问题?

DOJO SAMPLE

看起来这是内联编辑模式中的一个已知限制,但是有一个 workaround provided by Telerik here

解决方法与您为防止在编辑时进行编辑而添加的代码几乎相同,除了使用的选择器是跟踪 header 行上的 mousedown 以进行排序。

这是在完成 add/edit 时防止排序的变通方法代码:

$(".k-grid").on("mousedown", ".k-grid-header th", function (e) {
    // prevent sorting/filtering for the current Grid only
        var grid = $(this).closest(".k-grid");
        var editRow = grid.find(".k-grid-edit-row");

        // prevent sorting/filtering while any Grid is being edited
        //var editRow = $(".k-grid-edit-row");

        if (editRow.length > 0) {
            alert("Please complete the editing operation before sorting or filtering");
            e.preventDefault();
        }
});

我也有updated your dojo with the fix