0

),

我在 jqGrid 中使用内联编辑时遇到问题。我正在将一些网格从表单编辑切换到内联编辑。内联编辑的机制工作正常,但我试图在保存时将其他数据发送回服务器(我在使用表单编辑时使用 postData 来执行此操作)。我已将 editParams 设置为发回附加数据,如果我通过单击编辑铅笔编辑记录并通过单击导航栏中的保存图标进行保存,则此方法有效。但是,我注意到当我设置 keys: true 以便我可以使用 Escape/Enter 取消/保存记录和/或如果我通过双击行启动记录编辑时,editParams 不会被处理/发送到服务器. 我认为这是因为 editParams 是在编辑按钮的单击事件中设置的——我应该以某种方式利用它吗?

我错过了什么吗?感谢修复我的代码的任何帮助。

这是我的网格代码:

jQuery(document).ready(function() {jQuery('#grdRateEntries')
.jqGrid({
url: 'myUrl',
mtype: 'POST',
datatype: 'xml',
loadonce: false,
editurl: 'myEditUrl',
colNames: [
'ID', '', 'Type', 'Reported', 'Actual', 'Notes', 'Available', 'Paid', 'RateID'],
colModel: [

        {name: 'id', index:'id', hidden:true, editable:false, key:true},
        { name: 'act', index: 'act', width: ($.browser.webkit ? 40 : 35), align: 'center', sortable: false, formatter: 'actions',
            formatoptions: {
                keys: false, // we want to use [Enter] key to save the row and [Esc] to cancel editing.
                //delOptions: myDelOptions
                delbutton: false,
                editbutton: false
            }
        },
        {name:'ddlType', index:'ddlType', width:200, editable:true, edittype:'select', editrules:{required:true}, editoptions:{label:'Type', dataInit:function(el){InitType(el);}, value:':-- Select --;' }}, 
        {name:'ReportedUnits', index:'ReportedUnits', width:200, editable:true, editoptions:{size:10}, editrules:{number:true, required:true}}, 
        {name:'ActualUnits', index:'ActualUnits', width:200, editable:true, editoptions:{size:10}, editrules:{number:true, required:true}}, 
        {name:'Notes', index:'Notes', width:200, editable:true, editrules:{required:true}, editoptions:{rows:'2', cols:'30'}, edittype:'textarea'}, 
        {name:'Available', index:'Available', edittype:'checkbox', width:100, editable:true},
        {name:'Paid', index:'Paid', edittype:'checkbox', width:100, editable:false, editoptions:{size:25}},
        {name:'TypeID', index:'TypeID', hidden:true, editable:false}
        ],
recreateForm: false,
multiselect: false,
multiboxonly: false,
pager: jQuery('#pggrdRateEntries'),
rowNum:10,
rownumbers:true,
rowList:[5, 10, 20, 50],
sortname:'Id',
sortorder:'ASC',
viewrecords:true,
grouping:false,
imgpath:'',
caption:'',
autowidth:true,
shrinktofit:false,
toolbar: [true, 'top'],
postData:{entityId:1,employeeid:24,clientid:6},
        ondblClickRow: function(id)
        {
            if(id){ jQuery('#grdRateEntries').jqGrid('restoreRow',lastSel); jQuery('#grdRateEntries').jqGrid('editRow',id,true); lastSel=id; } 
        },
        loadComplete: function()
        {
            grid.setGridHeight('auto');
            grid.setGridWidth(700, false);

            var iCol = GetColumnIndexByName($('#grdRateEntries'), 'act');
            $(this).find('>tbody>tr.jqgrow>td:nth-child(' + (iCol + 1) + ')')
                .each(function(ndx) {
                    $('<div>', {
                        title: 'Set Actual=Reported',
                        mouseover: function() {
                            $(this).addClass('ui-state-hover');
                        },
                        mouseout: function() {
                            $(this).removeClass('ui-state-hover');
                        },
                        click: function(e) {
                            var selRowId = $(this).parents('tr').attr('id'); //$('#grdRateEntries').jqGrid('getGridParam', 'selrow');
                            var reportedVal = $('#grdRateEntries').jqGrid('getCell', selRowId, 'ReportedUnits');
                            $('#grdRateEntries').jqGrid('setCell', selRowId, 'ActualUnits', reportedVal);
                        }
                    }
                  ).css({'margin-right': '5px', float: 'left', cursor: 'pointer'})
                   .addClass('ui-pg-div ui-inline-custom')
                   .append('<span class="ui-icon ui-icon-copy"></span>')
                   .prependTo($(this).children('div'));
            });

        }
});
        $('#grdRateEntries').navGrid(
            '#pggrdRateEntries',
            {
                add: false,
                edit: false,
                del: true,
                refresh: true,
                search: false,
                view: false,
                edittitle: 'Edit selected record',
                addtitle: 'Add new record',
                deltitle: 'Delete selected record',
                cloneToTop:true,
                closeOnEscape:true
            }, // use default settings
            grdRateEntrieseditOptions,
            grdRateEntriesaddOptions,
            grdRateEntriesdeleteOptions, // use default settings for delete
            grdRateEntriessearchOptions
        );
        $('#grdRateEntries').jqGrid('inlineNav', 
            '#pggrdRateEntries',
            {
            editParams: {keys: false, extraparam: {entityId:1,employeeid:24,clientid:6}}
            }
        );

非常感谢您的帮助!

4

1 回答 1

0

您有以下用于内联编辑的回调函数。在“extraparam”的地方,您可以设置要发送的参数。

jQuery("#grid_id").jqGrid('editRow',rowid, keys, oneditfunc, successfunc, url, extraparam, aftersavefunc,errorfunc, afterrestorefunc);  
于 2013-07-23T11:00:01.780 回答