【发布时间】:2018-08-23 20:51:00
【问题描述】:
我正在使用 x-kendo-template 并使用函数使列在点击时可编辑。它所做的是擦除按钮,使所有列都可编辑,即使我已经在架构中指定了我想要保持为假的字段。
<div id="grid"></div>
var dataSource = new kendo.data.DataSource(
transport:{
read: function(options){
// code
},
update: function(options){
// code
},
cancel: function(options){
// code
},
parameterMap: function (options, operation) {
if (operation !== "read" && options.models) {
return { models: kendo.stringify(options.models) };
}
},
schema: {
model: {
id: "grid",
fields: [
Name: { type: "string", editable: false },
Value: { type: "string" }
]
}
}
}
);
<script id="template" type="text/x-kendo-template">
<a class="k-button k-button-icontext k-grid-update k-cust-update k-state-selected"><span class="k-update"></span>Update</a>
<a class="k-button k-button-icontext k-grid-cancel k-cust-cancel k-state-selected"><span class="k-cancel"></span>Cancel</a>
</script>
$('.k-grid-update').on('click', function(){
$("#grid").data("kendoGrid").setOptions({ editable: true });
});
因此,基于此,单击按钮后,名称不应可编辑,而值应不可编辑。
【问题讨论】:
-
schema.model
id:值可能不正确。 id: 值应该是数据记录中唯一标识每一行的字段的名称——在您的情况下,它可以是Name,或者可能是其他字段,例如rowId,它是数据库表。 -
您没有显示网格创建代码。你能用本地数据来创建一个可以工作的 Dojo 来证明这个问题吗?
标签: kendo-ui kendo-grid