【问题标题】:jqgrid inline edit only on selected cell, not the rowjqgrid 内联编辑仅在选定的单元格上,而不是行
【发布时间】:2012-12-03 05:46:52
【问题描述】:

我的应用程序中有一个 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>

【问题讨论】:

    标签: jquery asp.net-mvc jqgrid


    【解决方案1】:

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

    您的需求描述看起来您应该使用cell editing 而不是您当前使用的inline editing。

    【讨论】:

    • 所以有了这个网格,我的任何要求都是不可能的,即只编辑用户单击的单元格并在用户离开单元格时更新值?
    • @colorsbright:我需要提醒您,您可以免费获得带有完整源代码的产品。此外,您还可以找到许多展示如何使用它的示例。你相信有人会免费实现你的确切要求吗? jqGrid 在键盘导航期间保存单元格。如果您需要将其保存在focusout 或blur 上,您可以将您的事件处理程序与editoptions 的dataEvents 属性绑定并显式调用saveCell。
    • @colorsbright:我不确定你的意思。您可以使用所需的大多数控件。必须编写非常小或更长的 JavaScript 代码才能将控件包含在 jqGrid 中。例如,您可以轻松使用大多数 jQuery UI 控件,如日期选择器、自动完成等。 The demo 见the answer 和another 来自another answer 显示自定义控件的使用
    猜你喜欢
    • 2015-12-18
    • 2011-09-26
    • 1970-01-01
    • 2014-01-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多