2
根據問題「Filtering source in a Kendo Template」中的回答,我使用的是visible binding
。根據問題「Javascript inside Kendo Template is giving incorrect result」的答案,我避免了雙重約束。但visible
綁定不是它的功能。爲什麼它沒有做到過濾?Kendo UI可見綁定不起作用
CODE
<head>
<title>Template Filtering</title>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://cdn.kendostatic.com/2013.2.716/js/kendo.all.min.js"></script>
<!----Kendo Templates-->
<script id="row-template" type="text/x-kendo-template">
<tr data-bind="visible: IsSelected">
<tr>
<td>#= name #</td>
<td>#= age #</td>
</tr>
</tr>
</script>
<!--MVVM Wiring using Kendo Binding-->
<script type="text/javascript">
$(document).ready(function() {
kendo.bind($("body"), viewModel);
});
</script>
<script type="text/javascript">
var viewModel = kendo.observable({
employees: [
{ name: "Lijo", age: "28", IsSelected: true },
{ name: "Binu", age: "33", IsSelected: false },
{ name: "Kiran", age: "29", IsSelected: true }
],
// isVisibleCheck: function (e) {
// isValid = false;
// //person object is created using "e"
// var person = e.data;
// if (person.age >= 29) {
// isValid = true;
// }
// return isValid;
// }
});
</script>
<style>
table, th, td
{
border: 1px solid black;
}
</style>
</head>
<body>
<table id="resultTable">
<tbody data-template="row-template" data-bind="source: employees">
</tbody>
</table>
</body>
參考
- Visible binding in Kendo UI MVVM- docs.telerik
- Filtering source in a Kendo Template
- Javascript inside Kendo Template is giving incorrect result
Thanks..But我很奇怪,爲什麼是劍道給出不正確的結果,而不是拋出錯誤。這可能會導致很難找到的微妙的錯誤。如果這是一個更加親切的錯誤。 – Lijo
劍道走了沒有錯,所以沒有什麼可扔的。看看輸出的html。