2012-11-15 36 views
8

我有一个关于如何在kendo UI中实现只读编辑的问题。 请参阅下面的详细解释Kendo UI - 如何在创建可编辑Kendo网格的同时编辑特定字段?

我有以下字段:

名字(上创建可编辑)(上编辑编辑)
姓氏(上创建可编辑)(上编辑编辑)
用户名(可编辑的创建)(只读上编辑)
电子邮件(编辑上创建)(编辑在编辑)上创建
TelephoneNumber(编辑)(编辑在编辑)
PreWin2KUserName(而不是在创建编辑)(只读上编辑)

使用剑道UI网格参考链接 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

+0

相似:http://stackoverflow.com/questions/20881484/make-cell-readonly-in-kendo-grid-if-condition-is-met?lq=1 –

回答

8

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

$('#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'); 
     } 
    } 
}) 
+0

谢谢,我会检查对此并给予反馈。 – user1825918

+0

我试过这个,并没有工作! – GomuGomuNoRocket