剑道网格可编辑行问题

Kendo Grid editable row issue

本文关键字:问题 编辑 网格      更新时间:2023-09-26

我已经在一个plunk中复制了我所面临的问题。

我有一个剑道网格可编辑的行。

  1. 点击编辑&点击'Units In Stock'列的值,会导致警告弹出两次。
  2. 点击取消&然后再次点击同一列,弹出窗口只打开一次。

为什么会发生这种情况&我如何解决这个问题,所以弹出窗口只打开一次,即使行是在编辑模式。

$scope.grid.options = {
dataSource: $scope.dataSource,
pageable: true,
height: 550,
toolbar: ["create"],
columns: [
    "ProductName",
    { field: "UnitPrice", title: "Unit Price", format: "{0:c}", width: "120px" },
    { field: "UnitsInStock", title:"Units In Stock", width: "120px", template: '<a href="" ng-click="test(dataItem.UnitsInStock)">{{dataItem.UnitsInStock}}</a>'},
    { field: "Discontinued", width: "120px" },
    { command: ["edit", "destroy"], title: "&nbsp;", width: "250px" }],
editable: "inline"
};

观察者行为是由以下事实引起的:即使字段是不可编辑的,当网格处于内联编辑模式时,整个编辑行仍然是构建的,因此click事件处理程序被附加两次。

最直接的解决方法是在事件数据对象上调用stopImmediatePropagation()。下面是一个jQuery文档。