jqgrid仅在选定单元格上内联编辑,而不是行

时间:2012-12-03 05:46:53

标签: jquery asp.net-mvc jqgrid

我的应用程序中有一个jqgrid,它工作正常但与我的要求略有不同,当点击特定单元格时,整行被选中但我只想选择那个特定的单元格...下一个是能够在点击'Enter'键时更新行值,但我希望一旦用户离开该特定单元格就更新单元格值

这是我的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>

1 个答案:

答案 0 :(得分:2)

您似乎使用了错误的editing mode。 jqGrid支持树编辑模式,可以在许多变体中另外使用。

您的要求说明表明您应该使用cell editing而不是当前使用的inline editing

相关问题