gpt4 book ai didi

javascript - 如何无法使用剑道网格复选框?

转载 作者:行者123 更新时间:2023-12-02 13:58:35 25 4
gpt4 key购买 nike

代码片段中是网格的示例,我想当备注具有无效值时无法在网格中选中复选框。下面的代码中将有 3 个示例记录。输出: 第一个和第三个复选框设置为无法,第二个复选框启用以供用户选择。

var userRecord=[{reason:"Invalid",UserName:"test"},
{reason:"",UserName:"test1"},
{reason:"Invalid2",UserName:"test2"}]

var grid=$("#grid").kendoGrid({
columns: [
{ field: "", width: "40px", template: "<input name='Discontinued' class='checkbox' type='checkbox' />" },
{ field: "reason", title: "Remark" },
{ field: "UserName", title: "User Name" },


],
dataSource: {
data: userRecord
},
dataBound: function (e) {
$(".checkbox").bind("change", function (e) {
var grid = $("#grid").data("kendoGrid");
var row = $(e.target).closest("tr");
row.toggleClass("k-state-selected");
var data = grid.dataItem(row);
});
}
});
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="//kendo.cdn.telerik.com/2016.3.914/styles/kendo.common-bootstrap.min.css" />
<link rel="stylesheet" href="//kendo.cdn.telerik.com/2016.3.914/styles/kendo.bootstrap.min.css" />
<link rel="stylesheet" href="//kendo.cdn.telerik.com/2016.3.914/styles/kendo.bootstrap.mobile.min.css" />
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://kendo.cdn.telerik.com/2016.3.914/js/kendo.all.min.js"></script>

<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://kendo.cdn.telerik.com/2016.2.607/js/kendo.all.min.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<div id="grid"></div>
</body>
</html>

最佳答案

尝试这样的操作:#= (reason=='')? '禁用=禁用' : ''#

我不确定您是否想要禁用第一个和第三个,或者您想要禁用中间一个,但我认为您已经明白了。

var userRecord=[{reason:"Invalid",UserName:"test"},
{reason:"",UserName:"test1"},
{reason:"Invalid2",UserName:"test2"}]

var grid=$("#grid").kendoGrid({
columns: [
{ field: "", width: "40px", template: "<input name='Discontinued' class='checkbox' #= (reason=='')? 'disabled=disabled' : ''# type='checkbox' />" },
{ field: "reason", title: "Remark" },
{ field: "UserName", title: "User Name" },


],
dataSource: {
data: userRecord
},
dataBound: function (e) {
$(".checkbox").bind("change", function (e) {
var grid = $("#grid").data("kendoGrid");
var row = $(e.target).closest("tr");
row.toggleClass("k-state-selected");
var data = grid.dataItem(row);
});
}
});
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="//kendo.cdn.telerik.com/2016.3.914/styles/kendo.common-bootstrap.min.css" />
<link rel="stylesheet" href="//kendo.cdn.telerik.com/2016.3.914/styles/kendo.bootstrap.min.css" />
<link rel="stylesheet" href="//kendo.cdn.telerik.com/2016.3.914/styles/kendo.bootstrap.mobile.min.css" />
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://kendo.cdn.telerik.com/2016.3.914/js/kendo.all.min.js"></script>

<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://kendo.cdn.telerik.com/2016.2.607/js/kendo.all.min.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<div id="grid"></div>
</body>
</html>

关于javascript - 如何无法使用剑道网格复选框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40543975/

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