Kendo ui 剑道网格显示错误“;未捕获类型错误:无法读取属性';模板&x27;“未定义”的定义;

Kendo ui 剑道网格显示错误“;未捕获类型错误:无法读取属性';模板&x27;“未定义”的定义;,kendo-ui,kendo-grid,Kendo Ui,Kendo Grid,未捕获类型错误:无法读取未定义的属性“模板” 我使用剑道格网 我想在编辑时禁用列。(不是在添加新记录时)。编辑时是否编写代码 函数onEdit(e){ var indexCell=1; 变量网格=$('consumablesGrid')。数据('kendoGrid'); 如果(e.model.id){//在编辑id时已定义 if(indexCell!=“未定义”&&grid.columns[indexCell].title==“可消耗”){ grid.closeCell(); } } } 但执

未捕获类型错误:无法读取未定义的属性“模板”

我使用剑道格网

我想在编辑时禁用列。(不是在添加新记录时)。编辑时是否编写代码

函数onEdit(e){
var indexCell=1;
变量网格=$('consumablesGrid')。数据('kendoGrid');
如果(e.model.id){//在编辑id时已定义
if(indexCell!=“未定义”&&grid.columns[indexCell].title==“可消耗”){
grid.closeCell();
}
}
}
但执行
grid.closeCell()
时会显示
“未捕获类型错误:无法读取未定义的”
的属性“template”

为了更好地理解,我将包括我的完整网格条件

function ConsumableManager(){
$(“#consumablesGrid”).kendoGrid({
数据源:{
运输:{
阅读:{
url:“GetConsumablesGrid”,
类型:“POST”,
contentType:“应用程序/json”,
数据类型:“json”
},
更新:{
url:“UpdateConsumables”,
contentType:“应用程序/json”,
类型:“POST”,
数据类型:“json”,
完成:功能(数据){
var result=jQuery.parseJSON(data.responseText);
if(result.State==true){
toastr.成功(结果.说明);
$(“#consumablesGrid”).data(“kendoGrid”).dataSource.read();
}
否则{
toastr.error(结果说明);
$(“#consumablesGrid”).data(“kendoGrid”).dataSource.read();
}
}
},
销毁:{
网址:“销毁消耗品”,
contentType:“应用程序/json”,
类型:“POST”,
数据类型:“json”,
完成:功能(数据){
var result=jQuery.parseJSON(data.responseText);
if(result.State==true){
toastr.成功(结果.说明);
$(“#consumablesGrid”).data(“kendoGrid”).dataSource.read();
}
否则{
toastr.error(结果说明);
}
}
},
创建:{
url:“创建消耗品”,
contentType:“应用程序/json”,
类型:“POST”,
数据类型:“json”,
完成:功能(数据){
var result=jQuery.parseJSON(data.responseText);
if(result.State==true){
toastr.成功(结果.说明);
$(“#consumablesGrid”).data(“kendoGrid”).dataSource.read();
}
否则{
toastr.error(结果说明);
}
}
},
parameterMap:功能(数据、操作){
如果(操作!=“读取”){
返回kendo.stringify(data.models);
}
}
},
服务器分页:false,
页面大小:10,
批次:对,
模式:{
型号:{
id:“ConsumablesID”,
字段:{
ConsumablesID:{可编辑:false},
耗材:{可编辑:true},
单位成本:{可编辑:true},
货币:{可编辑:true},
压缩文件:{可编辑:false}
}
},
错误:“错误”
},
错误:函数(e){
警报(如错误+网格);
}
},
可编辑:
{
模式:“内联”,
createAt:“底部”
},
可分页:{
刷新:是的,
页面大小:正确
},
工具栏:[“创建”],
可排序:是的,
自动绑定:错误,
编辑:功能(e){
警告(“编辑”);
onEdit(e);
},
更新:职能(e){
},
柱:
[
{字段:“ConsumablesID”,宽度:50,隐藏:true,标题:“ID”},
{字段:“耗材”,宽度:200,标题:“耗材”,编辑器:ConsumablesDropDownEditor},
{字段:“单位成本”,宽度:100,标题:“单位成本”},
{字段:“货币”,宽度:200,标题:“货币”,编辑器:CurrencyUnitDropDownEditor},
{字段:“收缩”,宽度:85,隐藏:true,标题:“收缩”},
{命令:[“编辑”、“销毁”],标题:“操作”,宽度:“175px”}
]
});
$(“#consumablesGrid”).data(“kendoGrid”).dataSource.read();
}
任何人都知道为什么会发生这种情况。我怎么做请回答

我有一个网格


2.我想在编辑(不在添加中)时编辑(False)

您可能有太新的jquery版本:

当前剑道UI支持jquery 1.9.1。如果您将更高版本的jquery与剑道一起使用,您可能会遇到
closeCell()
的问题

要解决(解决)此问题,您可以使用

$('#consumablesGrid').getKendoGrid().trigger('cancel')

它取决于jquery版本,而不是
grid.closeCell()。
要避免此问题,可以使用此脚本

function onEdit(e) {
    if (!e.model.isNew() && (e.model != 'undefined') && (e.model != null)) {
        e.container.find("input[name=GroupName]").hide(); // To hide only the value of the column when updating the row
      //  e.container.find("#GroupName").parent().hide().prev().hide(); //to hide completely the column (value + structure + title name)
    }    
}

你的问题解决了吗?我不认为
“未捕获的TypeError:无法读取undefin的属性'template'