【发布时间】:2014-09-30 18:51:13
【问题描述】:
我在 jquery 中构建了一个剑道网格,我希望允许用户编辑它的特定单元格。问题是我知道有一种方法可以编辑整行,像这样:
$("#gridItens").kendoGrid({
editable: true,
columns: [
...
]
});
它工作正常,但正如我之前所说,它允许用户编辑整行,而不是特定的单元格。我尝试了类似上面的代码,但它不起作用。
$("#gridItens").kendoGrid({
columns: [
{ field: "Number", title: "Number", width: "10%", editable: true }
]
});
有没有办法让单元格可编辑?
谢谢 ;)
更新
我找到了解决方案。该解决方案与我所做的不同之处在于,每列的配置必须在架构部分中,而不是在列部分中。
$("#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%" }
]
});
【问题讨论】:
-
要编辑单元格,试试这个函数:console.log(cell.find("input"));
-
效果很好,谢谢!我必须在 kendoGrid 配置中添加
editable: true才能使其工作
标签: jquery kendo-grid