[英]Kendo UI grid does not show edited value, when using angular-kendo.js and the field is defined in the schema / model
在以下示例中,更新后的編輯后的名字將不會顯示。 但是,當我從dataSource.schema.model中刪除FirstName字段時,將顯示更改。
編輯之前
編輯
編輯后
在Kendo UI的Google Chrome開發人員擴展中,我可以看到firstName已從模型中刪除,並且在記錄中添加了屬性“ model”,而不是firstName屬性:
data: Array[7]
0: Object{3}
Id: 1
LastName: "ln_1"
models: Array[1]
0: Object{3}
Id: 1
FirstName: "fn_1_changed_to_something_else"
LastName: "ln_1"
1: Object{3}
Id: 2
FirstName: "fn_2"
LastName: "ln_2"
....
我究竟做錯了什么?
示例html頁面
<!doctype html>
<html ng-app="demoApp">
<head>
<meta charset="utf-8">
<title>Kendo UI directives for AngularJS</title>
<link href="//cdn.kendostatic.com/2014.1.318/styles/kendo.common.min.css" rel="stylesheet" type="text/css" />
<link href="//cdn.kendostatic.com/2014.1.318/styles/kendo.silver.min.css" rel="stylesheet" type="text/css" />
<script src="//code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="//cdn.kendostatic.com/2014.1.318/js/kendo.all.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular-route.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular-sanitize.js"></script>
<script src="/Scripts/angular-kendo.js"></script>
<script>
var demoApp = angular.module("demoApp", ["kendo.directives"]);
demoApp.controller('demoCtrl', function($scope) {
$scope.employees = [
{ Id: 1, FirstName: "fn_1", LastName: "ln_1" },
{ Id: 2, FirstName: "fn_2", LastName: "ln_2" },
{ Id: 3, FirstName: "fn_3", LastName: "ln_3" },
{ Id: 4, FirstName: "fn_4", LastName: "ln_4" },
{ Id: 5, FirstName: "fn_5", LastName: "ln_5" },
{ Id: 6, FirstName: "fn_6", LastName: "ln_6" },
{ Id: 7, FirstName: "fn_7", LastName: "ln_7" }
];
$scope.mainGridOptions = {
dataSource: {
data: $scope.employees,
batch: true,
pageSize: 5,
schema: {
model: {
id: "Id",
fields: {
FirstName: { type: "string", validation: { required: true } }
//LastName: { editable: true }
}
}
}
},
editable: "popup",
sortable: true,
pageable: true,
columns: [{
field: "FirstName",
title: "First Name",
width: "120px"
}, {
field: "LastName",
title: "Last Name",
width: "120px"
},
{
command: [{
name: "edit",
text: { edit: "Custom edit", cancel: "Custom cancel", update: "Custom update" }
}
, { name: "destroy", text: "Remove" }
]
}]
};
});
</script>
</head>
<body ng-controller="demoCtrl">
<div>
<div kendo-grid k-options="mainGridOptions"></div>
</div>
</body>
</html>
我發現了問題:處理本地數據時,不應使用數據源批處理選項。
如Mihai Bazon所確認。
將批處理選項更改為false后,一切再次正常運行。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.