Javascript 剑道UI网格:如何在条件下使单元格只读
在剑道UI网格(使用Angularjs)中,我有以下网格:Javascript 剑道UI网格:如何在条件下使单元格只读,javascript,jquery,angularjs,kendo-ui,kendo-grid,Javascript,Jquery,Angularjs,Kendo Ui,Kendo Grid,在剑道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 Prodott
<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"
};
但id不起作用(未定义引用)。尝试使用:
edit: function (e) {
if(myvar == true)
$("input[name=Price]").attr("readonly", true);
} else {
$("input[name=Price]").attr("readonly", false);
}
}
在网格的编辑功能中,只需按照您想要的方式操作条件。要关闭单元格,可以使用this.closeCell()强>
edit: function (e) {
//Size will be editable only when the Area is not empty
if(e.container.find(“input”).attr(“name”) == ‘Price’) {
//Below statement will close the cell and stops the editing.
if(myvar == true){
this.closeCell();
}
}
}
有关更多信息,请查看可能重复的
edit: function (e) {
//Size will be editable only when the Area is not empty
if(e.container.find(“input”).attr(“name”) == ‘Price’) {
//Below statement will close the cell and stops the editing.
if(myvar == true){
this.closeCell();
}
}
}
columns: [{
editable: false,
field: "Id",
title: "Id",
width: 50,
editor: idEditor,
}, {
title: "Name",
field: "Name",
width: 100
}, {
command: ["edit", "destroy"],
title: " ",
width: "250px"
}]
function idEditor(container, options) {
container.append(options.model.Id);
}