Jquery kendo 网格阻止在编辑模式下仅单击非编辑行

Jquery kendo grid prevent clicking only non edit rows when in edit mode

我目前正在使用 kendo 网格。我一直在尝试做的是,当我单击添加新行按钮时,会显示空行(k-grid-edit-row)。我想在编辑操作期间单击其他行时抛出一条警告消息并说先完成编辑操作。但关键是,我不想点击当前内联编辑行时显示提示信息

我现在所做的是,当我点击当前内联编辑行时,我也会收到一条警告消息。

    $('.k-grid-content').on("mousedown", function (e) {
        var grid = $('#Grid').closest(".k-grid");
        var editRow = grid.find(".k-grid-edit-row");
        if (editRow.length > 0) {
            alert("Please complete the editing operation before editing another row");
            e.preventDefault();
        }
        else return;
    });

您可以尝试查看被点击行的索引。当您添加一行时,该行到达顶部并且索引为 0。

在您的 if 语句中,还要检查索引是否不等于 0。

它看起来像 if grid.data("kendoGrid").select().index() != 0

我还没有对此进行测试,但我相信它应该有效。