我正在制作一个KendoUI TreeList表,我需要一些行是只读的。
由于默认情况下该选项不存在,我尝试按照本教程Here尝试执行此操作,该教程在KendoGrid上运行良好,但在我的树形运行中不起作用。
我定义了一个模板,该模板只为我标记为" readonly"的行创建了一个Edit按钮。
按钮显示但是当我点击它时没有任何反应......有没有人知道为什么?
以下是我制作的示例:http://dojo.telerik.com/EXupO/2
感谢您的帮助!
答案 0 :(得分:0)
请尝试使用以下代码段。我更改了编辑模板脚本的代码。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled</title>
<link rel="stylesheet" href="http://cdn.kendostatic.com/2015.1.429/styles/kendo.common.min.css">
<link rel="stylesheet" href="http://cdn.kendostatic.com/2015.1.429/styles/kendo.rtl.min.css">
<link rel="stylesheet" href="http://cdn.kendostatic.com/2015.1.429/styles/kendo.default.min.css">
<link rel="stylesheet" href="http://cdn.kendostatic.com/2015.1.429/styles/kendo.dataviz.min.css">
<link rel="stylesheet" href="http://cdn.kendostatic.com/2015.1.429/styles/kendo.dataviz.default.min.css">
<link rel="stylesheet" href="http://cdn.kendostatic.com/2015.1.429/styles/kendo.mobile.all.min.css">
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://cdn.kendostatic.com/2015.1.429/js/angular.min.js"></script>
<script src="http://cdn.kendostatic.com/2015.1.429/js/jszip.min.js"></script>
<script src="http://cdn.kendostatic.com/2015.1.429/js/kendo.all.min.js"></script>
</head>
<body>
<div id="example">
<div id="treelist"></div>
</div>
<script id="edit-template" type="text/x-kendo-template">
# if (!data.readonly) { #
<button data-command="edit" class="k-button k-button-icontext k-grid-edit"><span class="k-icon k-edit"></span>Edit</button>
# } #
</script>
<script>
$(document).ready(function () {
var editTemplate = kendo.template($("#edit-template").html());
var grid = $("#treelist").kendoTreeList({
dataSource: {
data: [{ DomainId: 1, Name: "Test", ReportsTo: null, readonly: true },
{ Name: "Categorie1", ReportsTo: 1, a: "10", b: "5" },
{ Name: "Categorie2", ReportsTo: 1, a: "10", b: "5" },
{ Name: "Categorie3", ReportsTo: 1, a: "10", b: "5" },
],
batch: true,
schema: {
model: {
id: "DomainID",
fields: {
parentId: { field: "ReportsTo", nullable: true, editable: false },
DomainID: { field: "DomainId", type: "number", editable: false },
Name: { validation: { required: true }, editable: false },
a: { type: "number", editable: true },
b: { type: "number", editable: true },
},
expanded: true
},
}
},
editable: true,
columns: [
{ field: "Name", title: "Domain", width: 400, editable: false },
{ field: "a", title: "1", filterable: false, sortable: false },
{ field: "b", title: "2", filterable: false, sortable: false },
{ field: "readonly", title: " ", width: 100, template: editTemplate, editor: function () { } }
],
editable: "popup",
pageable: true,
});
});
</script>
</body>
</html>
如果有任何疑虑,请告诉我。