gpt4 book ai didi

javascript - Kendo UI 可见绑定(bind)不起作用

转载 作者:行者123 更新时间:2023-11-29 19:42:33 25 4
gpt4 key购买 nike

基于问题“Filtering source in a Kendo Template”中的回答”,我正在使用 可见绑定(bind)。并基于问题“Javascript inside Kendo Template is giving incorrect result”中的答案”,我正在避免双重绑定(bind)。但是 visible 绑定(bind)并没有发挥它的作用。为什么过滤失败?

Fiddle

代码

<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>

引用文献

  1. Visible binding in Kendo UI MVVM- docs.telerik
  2. Filtering source in a Kendo Template
  3. Javascript inside Kendo Template is giving incorrect result

最佳答案

当我拿出多余的<tr></tr>时从您的 rowTemplate 来看,它似乎工作正常。

<tr data-bind="visible: IsSelected">
<td>#= name #</td>
<td>#= age #</td>
</tr>

查看示例... http://jsbin.com/vusav/1/edit

关于javascript - Kendo UI 可见绑定(bind)不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22097978/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com