【发布时间】:2018-06-20 13:29:57
【问题描述】:
我需要准备具有有限列数的网格,并且只有在编辑网格行时(在弹出窗口中)它才应该包含要编辑的其他字段。
如何编辑不属于网格列的网格弹出窗口中的字段?
【问题讨论】:
-
将您的数据源设置为包含您要显示或编辑的所有字段的模型。您可以选择要在网格的列集合中显示的列,但您可以编辑模型中的任何内容。
标签: kendo-ui telerik kendo-grid
我需要准备具有有限列数的网格,并且只有在编辑网格行时(在弹出窗口中)它才应该包含要编辑的其他字段。
如何编辑不属于网格列的网格弹出窗口中的字段?
【问题讨论】:
标签: kendo-ui telerik kendo-grid
您必须为弹出窗口设置模板,检查this:
<script id="popup-editor" type="text/x-kendo-template">
<h3>Edit Person</h3>
<p>
<label>Name:<input name="name" /></label>
</p>
<p>
<label>Age: <input data-role="numerictextbox" name="age" /></label>
</p>
<p>
<label>Active: <input type="checkbox" # if (data.active) { #checked="checked"# } #>
</p>
</script>
<div id="grid"></div>
<script>
$("#grid").kendoGrid({
columns: [
{ field: "name" },
{ field: "age" },
{ command: "edit" }
],
dataSource: {
data: [
{ id: 1, name: "Jane Doe", age: 30, active: false },
{ id: 2, name: "John Doe", age: 33, active: true }
],
schema:{
model: {
id: "id",
fields: {
age: { type: "number"}
}
}
}
},
editable: {
mode: "popup",
template: kendo.template($("#popup-editor").html())
}
});
</script>
【讨论】: