我只想在图标'A'点击上选择复选框。那我怎样才能找到复选框控件。
<a class="tooltip-top" onclick="GridArchiveAction(#: id #); " title="Archive" ><img src="/Content/images/Archive.png" style="cursor: pointer;"/></a>
file.js
var GridArchiveAction = function (id) {
if (confirm("Are you sure you want to archive this item?")) {
var grid = $('#Grid').data("kendoGrid");
var item = grid.dataSource.get(id);
var dataRow = grid.dataSource.getByUid(item.uid);
if (dataRow != undefined) {
dataRow.addClass("k-state-selected")
.find(".isLockedchkbx")
.prop("checked", "checked");
} else {
alert("You Must Select A Row To Archive A Record!");
}
}
};
答案 0 :(得分:0)
为什么需要复选框控制?
一般来说,你可以像
那样通过它onclick="GridArchiveAction(this, #: id #); "
//OR
var GridArchiveAction = function (this, id);`
您可以通过$(this)
获取复选框控件。
答案 1 :(得分:0)
请尝试使用以下代码段。
<body>
<div id="grid"></div>
<script>
$(document).ready(function () {
$("#grid").kendoGrid({
dataSource: {
type: "odata",
transport: {
read: "https://demos.telerik.com/kendo-ui/service/Northwind.svc/Customers"
},
pageSize: 20
},
height: 550,
groupable: true,
sortable: true,
pageable: {
refresh: true,
pageSizes: true,
buttonCount: 5
},
columns: [{
template: "<a class='tooltip-top' onclick='GridArchiveAction(this);' title='Archive' ><img src='http://www.naadsm.org/naadsm/files/common/smallZipFileIcon.png' style='cursor: pointer;'/></a>",
field: "ContactName",
title: "Contact Name",
width: 240
}, {
template: "<input class='isLockedchkbx' type='checkbox' />",
field: "ContactTitle",
title: "Contact Title"
}]
});
});
function GridArchiveAction(obj) {
if (confirm("Are you sure you want to archive this item?")) {
var grid = $('#grid').data("kendoGrid");
var row = $(obj).closest("tr");
$(row).find('.isLockedchkbx').prop("checked", "checked");
}
};
</script>
</body>
如果有任何疑虑,请告诉我。