模型是对象阵列。下面是我要检查的OnClick事件代码,取消选中基于PNR属性的其他复选框。如果相同的PNR复选框保持'ENABLED',否则'DISABLED'。我正在使用Kendo MVVM。
HTML code:
<td><input type="checkbox" data-bind="checked: IsSelected ,events: {click: OnTicketTstCheck},disabled: IsDisabled" /> </td>
script code:
function OnTicketTSTCheckProcess(e) {
debugger;
if ($(e.target).prop("checked") == true) {
var element = e.target;
var PNR = e.target.kendoBindingTarget.source.Pnr;
$.each(TicketviewModel.TicketVMList,
function(i, v) {
debugger;
if (v.Pnr == PNR) {
v.set("IsDisabled", false);
} else {
v.set("IsDisabled", true);
}
});
}
else {
var anyChecked = false;
var PNR = $(e.target).closest(".TicketItem").find(".pnr").text();
$.each(TicketviewModel.TicketVMList,
function(i, v) {
debugger;
if (v.IsSelected == true) {
anyChecked = true;
}
});
if (anyChecked == false) {
$.each(TicketviewModel.TicketVMList,
function(i, v) {
debugger;
v.set("IsDisabled", false);
});
}
}
}
当下面的行被执行时
v.set(“IsDisabled”,true);
取消选中所选复选框