【发布时间】:2014-05-23 04:11:14
【问题描述】:
我有一个 kendogrid 一切正常,现在我有了新的要求,即我有复选框的最后一列,就在前一列我有一个状态列,
如果该文本值为“CERTIFIED”,则应启用该特定行复选框,如果文本不是“CERTIFIED”,则应禁用该行的复选框,并且不应允许使用 jquery 检查该复选框,我附上了我的 kendogrid 的图片,这可能有助于提供任何建议
代码
这些是我的剑道网格中的列
, columns: [
{ field: "ResultFormatID", Title: "ResultFormatID", filterable: false, sortable: false, hidden: true },
{ field: "ID", Title: "ID", filterable: false, sortable: false, hidden: true },
{ field: "RowID", Title: "RowID", filterable: false, sortable: false, hidden: true },
{ field: "BillNumber", Title: "Bill Number", filterable: false, sortable: false, hidden: true },
{ field: "ServiceName", Title: "Service Name", width: 600 },
{ field: "Status", Title: "Service Status", width: 150 }
, {
template: $("#template").html(),
headerTemplate: '<label> <input type="checkbox" id="checkAll"/>Download</label>', filterable: false, sortable: false, width: 100,
}
]
这是我的个人行复选框
<script id="template" type="text/kendo-template">
#if(ResultFormatID != 3) { #
<input type="checkbox" #= data.Action ? checked="checked" : "" # class=\"check_row\"/>
# } else { #
<input type="button" class="k-button info" name="info" value="Preview" />
# } #
更新
这是我的检查功能(以及我取消选中的操作)
$("#checkAll").on('click', function (e) {
debugger;
var $cb = $(this);
var checked = $cb.is(':checked');
var grid = $('.Grid_table').data('kendoGrid');
grid.table.find("tr").find("td:last input").attr("checked", checked);
var items = $(".Grid_table").data("kendoGrid").dataSource.data();
for (i = 0; i < items.length; i++) {
var item = items[i];
var status = item.ServiceStatus;
if (status == "Result Certified ") {
grid.table.find("tr").find("td:last input").attr("checked", checked);
}
else {
grid.table.find("tr").find("td:last input").prop("checked",false);
}
if (!checked) {
// debugger;
$(".Grid_table").data("kendoGrid").clearSelection();
}
});
});
更新 2
现在根据您的代码,一切正常,我可以取消选中未认证的行,我面临以下代码的问题,如果未选中至少一个复选框,它禁用了用于下载 PDF 的按钮文件,现在如果我选择所有复选框并单击该按钮下载,它现在被禁用!但如果我取消选中 10 行中的任何一行,则下载启用并用于下载文件。
如果我禁用下面代码的最后 3 行,它有助于使按钮能够单击,但我需要取消选择至少一个复选框才能工作,如果不是它将被禁用,我做错了什么??
$(function () {
//debugger;
var checkboxes = $(':checkbox:not(#checkAll)').click(function (event) {
$('#btn_Print').prop("disabled", checkboxes.filter(':checked').length == 0);
});
$('#checkAll').click(function (event) {
checkboxes.prop('checked', this.checked);
$('#btn_Print').prop("disabled", !this.checked)
});
});
如果
【问题讨论】:
标签: jquery asp.net-mvc-4 checkbox kendo-grid