Jqgrid内联编辑具有互斥条件

时间:2015-03-11 09:57:45

标签: jquery jqgrid grid

jquery grid 中是否有任何功能,一次只允许单行编辑?目前我们可以编辑多行。

1 个答案:

答案 0 :(得分:2)

上述查询由我的同事发布。我们正在使用以下代码。

我们正在使用Jquery.jqgrid-4.1.2.min.js

场景是:它允许我们同时编辑多行,但是一旦光标在另一行上移动,第一行的保存和取消按钮仍然存在

        $("#AllocationsGrdList").jqGrid({
            url: '@Url.Action("ActionName", "Controller")/',
            datatype: "json",
            colNames: ['Category Name','Amount','Edit'],
            colModel: [
                { name: 'CategoryName', index: 'CategoryName', sortable: true, sorttype: 'text', width: 140, classes: 'bStyle' },
                {
                    name: 'Amount', index: 'Amount', width: 82, align: "right", editable: true, editrules: { number: true, required: true, custom: true, custom_func: Deductions }, formatter: 'currency',
                    formatoptions: { decimalSeparator: ".", thousandsSeparator: ",", decimalPlaces: 2, defaultValue: '0.00', prefix: '$ ' },
                    editoptions: {
                        style: 'width:70px;', dataEvents: [
                           {
                               type: 'blur',
                               fn: function (e) {
                                   CalculateDeductions($(this).val());// SOme DB Operation

                               }
                           }
                        ]
                    }
                },
                {
                    name: 'act', index: 'act', width: 60, align: 'center', sortable: false, formatter: 'actions',
                    formatoptions: {
                        keys: false,
                        delbutton: false,
                        onEdit: function (rowid) {
                        },
                        onSuccess: function (jqXHR) {
                            $("#AllocationsGrdList").trigger('reloadGrid');
                            return true;
                        },
                        onError: function (rowid, jqXHR, textStatus) {

                        },
                        afterSave: function (rowid) {
                        },
                        afterRestore: function (rowid) {
                            $("#AllocationsGrdList").trigger('reloadGrid');   
                        }
                    }
                }
            ],
            rowNum: 10, rowList: [10, 20, 30],
            sortname: 'CategoryName',
            shrinkToFit: true,
            sortable: true,
            viewrecords: true,
            sortorder: "desc",
            footerrow: true,
            width: '780',
            height: '100%',
            jsonReader:
                {
                    root: 'List',
                    page: 'Page',
                    total: 'TotalPages',
                    records: 'TotalCount',
                    repeatitems: false,
                    id: 'Id'
                },

            editurl: '@Url.Action("ActionName", "ControllerName")'
        });