Kendo Grid jQuery - 可编辑单元格
我有一个kendo网格生成在jquery中,我想允许用户编辑它的特定单元格。问题是,我知道有个编辑的整条生产线,像这样的方法:Kendo Grid jQuery - 可编辑单元格
$("#gridItens").kendoGrid({
editable: true,
columns: [
...
]
});
它工作正常,但正如我之前说的,它允许用户编辑整条生产线,而不是特定的细胞。我尝试了类似上面的代码,但它不起作用。
$("#gridItens").kendoGrid({
columns: [
{ field: "Number", title: "Number", width: "10%", editable: true }
]
});
有没有什么办法让单元格可编辑?
感谢)
UPDATE
我发现了一个解决方案。解决方案与我所做的不同之处在于每个列的配置必须位于模式部分,而不是列部分。
$("#gridItens").kendoGrid({
dataSource: {
type: "json",
transport: {
read:
{
url: "/RC/BuscarItensContrato",
data: { contratoId: 0 },
contentType: "application/json; charset=utf-8",
dataType: "json"
}
},
schema: {
model: {
fields: {
Id: { type: "number" },
Descricao: { type: "string", editable: false },
Numero: { type: "number", editable: true }
}
}
}
},
columns: [
{
field: "Selecionado",
title: "",
sortable: false,
width: 30,
headerTemplate: "<input type='checkbox' id='chkSelectAll' />",
template: "<input type='checkbox' name='gridcheckbox' id='#=Id#' />"
},
{ field: "Descricao", title: "Descrição", width: "30%" },
{ field: "Numero", title: "Número", width: "10%" }
]
});
注意这是剃须刀的语法。
@(Html.Kendo().Grid<ViewModel>()
.Name("grid")
.Editable(editable => editable.Mode(GridEditMode.InCell))
.Columns(columns =>
{....
}
不允许字段为可编辑
.DataSource(dataSource => dataSource
.Ajax()
.Read(etc....)
.Model(model =>
{
model.Field(x => x.Property).Editable(false);
}
问题是我不能使用剃须刀语法,只有jQuery – 2014-09-30 19:30:21
试试这个'editable:“incell”' – CSharper 2014-09-30 19:33:31
好吧,如果我配置可编辑:“incell”,然后为每个列设置editable:false或true,它允许编辑所有单元格,如果可编辑被定义为false,则无关紧要。 – 2014-09-30 19:42:05
要编辑单元格,试试这个功能:执行console.log(cell.find( “输入”)); – Juniar 2014-09-30 19:50:24
作品很好,谢谢!我必须添加'editable:true'到kendoGrid配置才能使其工作 – 2016-03-01 06:13:06