在 Kendo UI 网格(使用 Angularjs)中,我有以下网格:
<div kendo-grid k-data-source="Table" k-options="thingsOptions" style="height: 365px">
$scope.thingsOptions = {
sortable: "true",
scrollable: "true",
toolbar: [{ name: "create", text: "Aggiungi Prodotto" }],
columns: [
{ field: "Name", title: "Name", width: "50px" },
{ field: "Description", title: "Description", width: "50px" },
{ field: "Price", title: "Price", width: "50px" },
{ field: "Active", title: "Active", template: '<input type="checkbox" disabled="disabled" #= Active ? checked="checked":"" # class="chkbx" />', width: "20px" },
{ command: [{ name: "edit", text: "Modifica" }], title: "", width: "172px" }
],
editable: "inline"
};
如何在某些情况下使“价格”字段只读?我必须测试一个变量,如果它是真的,我希望 Price 字段只读,否则可写。
我尝试添加“thingsOptions”功能:
edit: function (e) {
if(myvar == true)
e.container.find("input[name=Price]").enable(false);
}
但是 id 不起作用( undefined reference )。
最佳答案
尝试使用:
edit: function (e) {
if(myvar == true)
$("input[name=Price]").attr("readonly", true);
} else {
$("input[name=Price]").attr("readonly", false);
}
}
关于javascript - 剑道 UI 网格 : how to make cell read only on condition,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24141773/