我已在 plunk 中重现了我遇到的问题.
我有一个带有可编辑行的剑道网格。
- 点击“编辑”并点击“库存单位”列的值,导致弹出警报两次。
- 点击“取消”,然后再次点击同一列,弹出窗口仅打开一次。
为什么会发生这种情况以及如何解决此问题,因此即使该行处于编辑模式,弹出窗口也只会打开一次。
$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: " ", width: "250px" }],
editable: "inline"
};
最佳答案
观察者行为是由于以下事实引起的:即使该字段不可编辑,当网格处于内联编辑模式时,仍然会构建整个编辑行,因此单击事件处理程序会附加两次。
最直接的解决方法是对事件数据对象调用 stopImmediatePropagation()
。这是jQuery文档相同。
看看这个 plunk .
关于javascript - Kendo Grid 可编辑行问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40050061/