【发布时间】:2021-08-24 13:10:33
【问题描述】:
背景
我有一个带有复选框、下拉列表和日期选择器的 Kendo Grid。我正在使用行模板功能在网格上添加这些控件。下面是我的网格的代码。
这就是我构建剑道网格的方式
$("#firstReqGrid").kendoGrid({
dataSource: dataSource,
pageable: true,
height: 430,
toolbar: ["save"],
columns: [
{ field: "claimId", title: "ClaimID", width: 40 },
{ field: "lineCnt", title: "Lines", width: 10 },
{ title: "Med Requested", field: "medRecRequested", template: '<input type="checkbox" #= medRecRequested ? \'checked="checked"\' : "" # class="chkbx" />', width: 25, editable: function (e) { return false; } },
{ title: "EOB", field: "eobChk", template: '<input type="checkbox" #= eobChk ? \'checked="checked"\' : "" # class="chkbx" />', width: 25, editable: function (e) { return false; } },
{ title: "Claim", field: "clmChk", template: '<input type="checkbox" #= clmChk ? \'checked="checked"\' : "" # class="chkbx" />', width: 25, editable: function (e) { return false; } },
{ field: "MedRecRcvd", title: "Med Rec Rcvd", width: "30px", editor: medRecRcvdDropDownEditor, template: "#=MedRecRcvd.MedRecRcvdName#" },
{
field: "dateReceived", title:"Date Rcvd", format: "{0:dd MMM yyyy}", width: 30, editor: function (container, options) {
var input = $("<input/>");
input.attr("name", options.field);
input.appendTo(container);
input.kendoDatePicker({});
}
},
{ title: "Memo", width: 40, template: '<input type="k-button" onclick="return addMemo(#=claimId#)" class="k-button" name="btnMemo" value="Memo" />' }],
editable: true,
dataBound: function (e) {
/* This code disables all the checkboxes in the grid*/
$("#firstReqGrid :input").attr("disabled", true);
// var grid = $("#firstReqGrid").data("kendoGrid");
// var pageSizeDropDownList = grid.wrapper.children.find(".k-dropdown select").data("kendoDropDownList");
//var dropDown = e.container.find("[data-role='dropdownlist']").data("kendoDropDownList");
//if (dropDown) {
// dropDown.readonly();
//}
}
});
我正在努力实现的目标
如果满足某些条件,我希望能够禁用 Datepicker 和 Dropdownlist。我计划在网格的数据绑定事件中检查那些“条件”,如果满足条件,则禁用日期选择器和下拉列表。我知道 datepicker.enable(false) 事件,但为了做到这一点,我需要一个在这种情况下没有的 id。下拉列表列表也是如此;我需要一个 ID 来禁用该属性。我需要有关如何使用我布置的代码为 datepicker 和 dropdownlist 添加 ID 的帮助。这样我就可以在网格数据绑定事件中引用该 ID 并打开禁用属性。或者,如果有任何其他方式我愿意提供建议。非常感谢。
【问题讨论】:
-
您想要禁用它们还是只是不想让用户编辑记录?
-
@David 我希望禁用日期选择器和下拉菜单。这基本上不允许用户编辑记录。
-
我问的原因是因为您可以阻止用户编辑记录而不必担心禁用输入。但如果你特别想禁用输入,那就完全不同了。
标签: javascript jquery kendo-ui kendo-grid