如何仅在客户端UI上使kendo网格列不可编辑,但我可以在脚本中为其设置值?
var dataSource = new kendo.data.DataSource({
data: result,
schema: {
model: {
fields: {
IsSelected:{type:"boolean",editable:true},
InvoiceDate: { type: "date",editable:false }
}
}
}
});
kendo Grid
$('#grdClaim').kendoGrid({
height: "300px",
sortable: true,
resizable: true,
filterable: true,
editable:true,
columns: [
{
sortable: false,
filterable: false,
width: '30px',
field: "IsSelected",
title: "<input type='checkbox' id='chkSelectAll' onclick='checkAll()'checked/>",
template: '<input type="checkbox" id="selectedIds" name="selectedIds" #= IsSelected ? \'checked="checked"\' : "" # class="chkbx"/> ',
}]});
我需要做的是在我的Js代码上编辑字段“IsSelected”而不能在网格上编辑它的值?像:
var grid = $("#grdClaim").data("kendoGrid");
var dataItem = grid.dataItem($(e.target).closest("tr"));
dataItem.set("IsSelected", $(e.target).is(":checked") ? 1 : 0);
注意:我正在使用kendo 2013
答案 0 :(得分:0)
您可以在模板中设置已停用属性,如下所示,使列不可编辑
columns: [
{
sortable: false,
filterable: false,
width: '30px',
field: "IsSelected",
title: "<input type='checkbox' id='chkSelectAll' onclick='checkAll()'checked/>",
template: '<input type="checkbox" disabled="disabled" id="selectedIds" name="selectedIds" #= IsSelected ? \'checked="checked"\' : "" # class="chkbx"/> ',
}]