2012-12-03 54 views
3

我有一个jqgrid在我的应用程序,它工作正常,但它与我的要求略有不同,当点击一个特定的单元格时,整行被选中,但我只需要选择特定的单元格...下一个可以更新点击“Enter”键时的行值,但是我希望只要用户离开该特定单元格就更新单元格的值jqgrid内联编辑只在选定的单元格,而不是行

这是我的jQuery代码

<script type="text/javascript"> 
    $(function() { 
     var lastsel; 

     jQuery("#list").jqGrid({ 
      url: '/Home/GetStudents/', 
      datatype: 'json', 

      mtype: 'POST', 
      colNames: ['StudentID', 'FirstName', 'LastName', 'Email'], 
      colModel: [ 
     { name: 'StudentID', sortable: false, key: true }, 
     { name: 'FirstName', key: true }, 
     { name: 'LastName', sortable: false, key: true }, 
     { name: 'Email', width: 200, sortable: false, key: true}], 
      cmTemplate: { align: 'center', editable: true }, 
      pager: '#pager', 
      width: 750, 
      rowNum: 15, 
      rowList: [5, 10, 20, 50], 
      sortname: 'StudentID', 
      sortorder: "asc", 
      viewrecords: true, 
      caption: ' My First JQgrid', 
      onSelectRow: function (StudentID) { 


       if (StudentID != lastsel) { 


        jQuery('#list').jqGrid('restoreRow', lastsel); 
        jQuery('#list').jqGrid('editRow', StudentID, true); 

        lastsel = StudentID; 

       } 

      }, 

      editurl: '/Home/About/', 

      caption: "jQgrid Sample" 

     }); 

     jQuery("#list").jqGrid('navGrid', "#pager", { edit: false, add: false, del: false }); 
    }); 

</script> 

回答

2

你好像用错editing mode。 jqGrid支持树编辑模式,可以在许多变体中使用。

您的要求的描述看起来应该使用cell editing而不是您目前使用的inline editing

+0

所以在这个网格中,我的任何需求都是不可能的,例如只编辑用户在离开单元格时点击并更新值的单元格? –

+0

@colorsbright:我需要提醒您,您获得的产品包含* free *的完整源代码。此外,您可以找到很多示例来说明如何使用它。你相信有人会免费实施你的确切要求吗? jqGrid在键盘导航过程中保存单元格。如果您需要将其保存在'focusout'或'blur'上,则可以将您的事件处理程序与[editoptions]的[dataEvents'属性相关联(http://www.trirand.com/jqgridwiki/doku.php?id = wiki:common_rules#editoptions)并显式调用'saveCell'。 – Oleg

+0

okk,明白了,所以这是一个免费的第三方控制? –

相关问题