我们在实施层次网格时遇到了问题,因为我们在使用自定义数据源复制功能时遇到了一些困难,如下图所示:
var DataSource1 = [
{ ID: “1” , FirstName: “John”, Lastname: “Smith”, Title: “Mr”},
{ ID: “2” , FirstName: “Jane”, Lastname: “Doe”, Title: “Miss”},
{ ID: “3” , FirstName: “Bruce”, Lastname: “Wayne”, Title: “MR”}
];
var DataSource2 = [
{ ID: “1” , Data1: “1001”, Data2: “2900”, Data3 “Y”},
{ ID: “2” , Data1: “1002”, Data2: “2901”, Data3 “Y”},
{ ID: “3” , Data1: “1003”, Data2: “2902”, Data3 “N”}
];
我们需要以下问题的帮助:-
我们如何根据 ID 创建详细链接,即当客户端单击 Tab 按钮时,它只显示 ID 1 的数据源?
+--------------+---+------+-------+----+
| | 1 | John | Smith | MR |
+--------------+---+------+-------+----+
| Detailed Tab | 1 | 1001 | 2900 | Y |
+--------------+---+------+-------+----+
您能否建议如何使用本地数据源实现这一点,我们正在使用 Java 脚本在 HTML 中进行开发。
请在下面找到我们试图让过滤器工作的示例代码
<!DOCTYPE html>
<html>
<head>
<title>Detail template</title>
<link href="../../content/shared/styles/examples-offline.css" rel="stylesheet">
<link href="../../../styles/kendo.common.min.css" rel="stylesheet">
<link href="../../../styles/kendo.default.min.css" rel="stylesheet">
<script src="../../../js/jquery.min.js"></script>
<script src="../../../js/kendo.web.min.js"></script>
<script src="../../content/shared/js/console.js"></script>
<script>
</script>
</head>
<body>
<script type="text/x-kendo-template" id="template">
<div class="tabstrip">
<ul>
<li class="k-state-active">
Orders
</li>
</ul>
<div>
<div class="orders"></div>
</div>
</div>
</script>
<div id="grid1"></div>
<script>
var DataSource1 = [
{ ID: "1" ,Fristname: "Jhon", Lastname: "Smith", Title: "Mr"},
{ ID: "2" ,Fristname: "Jane", Lastname: "Doe", Title: "Miss"},
{ ID: "3" ,Fristname: "Bruce", Lastname: "Wayne", Title: "MR"}, ];
var DataSource2 = [
{ ID: "1" , Data1: "1001", Data2: "2900", Data3: "Y"},
{ ID: "2" , Data1: "1002", Data2: "2901", Data3: "Y"},
{ ID: "3" , Data1: "1003", Data2: "2902", Data3: "N"}, ];
$("#grid1").kendoGrid({
dataSource: DataSource1,
detailInit: detailInit,
detailTemplate: kendo.template($("#template").html()),
toolbar: ["save", "cancel"],
columns: [
{ field:"ID",title:"ID" },
{ field:"Fristname",title:"Fristname" },
{ field:"Lastname",title:"Lastname" },
{ field:"Title",title:"Title" },
],
editable : true,
});
function detailInit(e) {
var detailRow = e.detailRow;
detailRow.find(".tabstrip").kendoTabStrip({
animation: {
open: { effects: "fadeIn" }
}
});
detailRow.find(".orders").kendoGrid({
dataSource: DataSource2,
filter: { field: "ID", operator: "eq", value: e.data.ID },
scrollable: false,
sortable: true,
pageable: true,
columns: [
{ field:"ID",title:"ID" },
{ field:"Data1",title:"Data1" },
{ field:"Data2",title:"Data2" },
{ field:"Data3",title:"Data3" },
],
editable : true,
});
}
</script>
</body>
</html>
谢谢,