【问题标题】:Kendo UI - How to make specific fields readonly on edit while on create its editable in kendo grid?Kendo UI - 如何在编辑时使特定字段只读,同时在剑道网格中创建可编辑?
【发布时间】:2012-11-03 19:29:27
【问题描述】:

我有一个关于如何在 kendo UI 中实现 readonly on edit 的问题。 详细解释见下文

我有以下字段:

名字(创建时可编辑)(编辑时可编辑)
姓氏(创建时可编辑)(编辑时可编辑)
用户名(创建时可编辑)(编辑时只读)
电子邮件(创建时可编辑)(编辑时可编辑)
电话号码(创建时可编辑)(编辑时可编辑)
PreWin2KUserName(创建时不可编辑)(编辑时只读)

使用 Kendo UI Grid 参考链接 http://demos.kendoui.com/web/grid/editing-inline.html

加上这个来实现 http://www.kendoui.com/forums/ui/grid/making-column-as-readonly-on-update-and-editable-on-insert-in-grid.aspx

【问题讨论】:

标签: kendo-ui


【解决方案1】:

您可以使用网格的edit event。如果模型不是新模型,即用户正在编辑(而不是创建)记录,则您将只读属性附加到所需的输入元素。

$('#yourGrid').kendoGrid({
     // ...
     edit: function(e) {
         if (!e.model.isNew()){
             // make sure the UserName id selector is correct in your code
             // (it should be, for a regular text input)
             $('#UserName').attr('readonly', 'readonly');
         }
     }
})

【讨论】:

  • 谢谢,我会检查并提供反馈。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-04-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多