是否存在與Kendo Grid的onEditComplete等價的事件,其中事件僅在單元格的內容被編輯後觸發?Kendo Grid相當於onEditComplete
Documentation提到「編輯」事件,但是一旦單元格進入編輯模式就會觸發(所以這相當於onBeginEdit)。
我發現的具有所需行爲的最接近事件是「保存」事件,但此事件僅在單元格內容發生更改時觸發。我希望一旦細胞退出編輯模式就會觸發事件。
網格的editmode設置爲incell。
是否存在與Kendo Grid的onEditComplete等價的事件,其中事件僅在單元格的內容被編輯後觸發?Kendo Grid相當於onEditComplete
Documentation提到「編輯」事件,但是一旦單元格進入編輯模式就會觸發(所以這相當於onBeginEdit)。
我發現的具有所需行爲的最接近事件是「保存」事件,但此事件僅在單元格內容發生更改時觸發。我希望一旦細胞退出編輯模式就會觸發事件。
網格的editmode設置爲incell。
所以由於評論我已經打消了我以前的答案 - 使用的輸入框(或其他元素的blur事件)似乎工作:
在grid.edit事件上,使用jquery綁定到文本框(或任何其他內聯編輯控件)的blur事件時會在焦點丟失時觸發。將此附加到網格定義中......並且顯然將您的代碼替換爲警報。
edit: function (e) {
alert('Edit Fired');
$('input.k-input.k-textbox').blur(function() {
alert('blur event called');
});
},
我已經通過修改樣本聯編輯代碼here
編輯的我完全本地源測試,這一點 - 只看到對電網高清編輯事件:
<div id="example" class="k-content">
<div id="grid"></div>
<script>
$(document).ready(function() {
var crudServiceBaseUrl = "http://demos.kendoui.com/service",
dataSource = new kendo.data.DataSource({
transport: {
read: {
url: crudServiceBaseUrl + "/Products",
dataType: "jsonp"
},
update: {
url: crudServiceBaseUrl + "/Products/Update",
dataType: "jsonp"
},
destroy: {
url: crudServiceBaseUrl + "/Products/Destroy",
dataType: "jsonp"
},
create: {
url: crudServiceBaseUrl + "/Products/Create",
dataType: "jsonp"
},
parameterMap: function (options, operation) {
if (operation !== "read" && options.models) {
return { models: kendo.stringify(options.models) };
}
}
},
batch: true,
pageSize: 20,
schema: {
model: {
id: "ProductID",
fields: {
ProductID: { editable: false, nullable: true },
ProductName: { validation: { required: true } },
UnitPrice: { type: "number", validation: { required: true, min: 1 } },
Discontinued: { type: "boolean" },
UnitsInStock: { type: "number", validation: { min: 0, required: true } }
}
}
}
});
$("#grid").kendoGrid({
dataSource: dataSource,
pageable: true,
height: 430,
toolbar: ["create"],
// added in hook to here to bind to edit element events.
// blur is fired when an element loses focus
edit: function (e) {
alert('Edit Fired');
$('input.k-input.k-textbox').blur(function (e) {
alert('blur event called');
});
},
columns: [
"ProductName",
{ field: "UnitPrice", title: "Unit Price", format: "{0:c}", width: "100px" },
{ field: "UnitsInStock", title: "Units In Stock", width: "100px" },
{ field: "Discontinued", width: "100px" },
{ command: ["edit", "destroy"], title: " ", width: "172px" }],
editable: "inline"
});
});
</script>
</div>
我遠程綁定了數據源,使用這將意味着事件在數據源本身發生更改時被觸發。我希望數據源完好無損,如果單元格退出編輯模式,我實際上只需要觸發事件。 – l46kok 2013-06-06 07:35:46
我設法掛鉤到文本框中的模糊事件,應該只在文本框失去焦點時觸發 - 我已經測試過。如果你想鉤入除文本框之外的任何其他元素,只需更改grid.edit事件代碼中的jquery選擇器 - 請參閱我的編輯 – 2013-06-06 09:02:14
您是否嘗試過Change Event
「改變
當用戶選擇網格中的一個錶行或單元格被解僱。」
示例 - 使用電池時選擇獲得所選擇的數據項目(S)
<div id="grid"></div>
<script>
function grid_change(e) {
var selectedCells = this.select();
var selectedDataItems = [];
for (var i = 0; i < selectedCells.length; i++) {
var dataItem = this.dataItem(selectedCells[i].parentNode);
if ($.inArray(dataItem, selectedDataItems) < 0) {
selectedDataItems.push(dataItem);
}
}
// selectedDataItems contains all selected data items
}
$("#grid").kendoGrid({
columns: [
{ field: "name" },
{ field: "age" }
],
dataSource: [
{ name: "Jane Doe", age: 30 },
{ name: "John Doe", age: 33 }
],
selectable: "multiple, cell"
});
var grid = $("#grid").data("kendoGrid");
grid.bind("change", grid_change);
</script>
同樣,正如在OP中明確規定的那樣,我需要一個在單元格上編輯完成時觸發的事件。你的建議與onBeginEdit差不多。我需要的是onEditComplete。 – l46kok 2013-06-06 06:00:01
爲什麼你沒有使用「模糊」事件?
http://www.kendoui.com/forums/ui/window/possible-to-close-window-when-it-loses-focus-.aspx
$("#window").blur(function(){
if ($(document.activeElement).closest(".k-window").length == 0) {
$("#window").data("kendoWindow").close();
}
});
此事件是否適用於具有incell編輯模式的網格? – l46kok 2013-06-06 07:36:43
從我所知道的沒有像「onEditComplete」這樣的事件。但你可以用CSS選擇器獲取元素並設置模糊功能。這個:「.k-grid-content> table> tbody> tr> td」將成爲http://demos.kendoui.com/web/grid/editing-custom.html的css選擇器。 – user23031988 2013-06-06 08:28:24
由於這個問題似乎已經開放三年了,而且Telerik沒有提供正式的解決方案 - 您是否在Telerik開放功能請求?網格中有一個「itemChange」事件,但它沒有記錄,也沒有告訴你列名。 – Rolf 2016-04-14 13:57:34