【问题标题】:How to edit fields in grid popup that are not part of grid columns?如何编辑不属于网格列的网格弹出窗口中的字段?
【发布时间】:2018-06-20 13:29:57
【问题描述】:

我需要准备具有有限列数的网格,并且只有在编辑网格行时(在弹出窗口中)它才应该包含要编辑的其他字段。

如何编辑不属于网格列的网格弹出窗口中的字段?

【问题讨论】:

  • 将您的数据源设置为包含您要显示或编辑的所有字段的模型。您可以选择要在网格的列集合中显示的列,但您可以编辑模型中的任何内容。

标签: kendo-ui telerik kendo-grid


【解决方案1】:

您必须为弹出窗口设置模板,检查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>

Demo

【讨论】:

  • 只有当用户想要编辑某行时,是否可以为网格行寻找额外的数据来编辑?换句话说:网格是用 f.e. 的数据源定义的。 4 个字段,但通过编辑弹出窗口,我想再检索 50 个字段供该行进行编辑。
  • @Sruj 附加数据在哪里?
  • 在服务器上,我可以在 json 中检索它。我创建了新主题stackoverflow.com/questions/50966712/…
猜你喜欢
  • 1970-01-01
  • 2013-05-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多