Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/475.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jqGrid:为什么不';我为网格编辑触发定义的事件是什么?_Javascript_Jquery_Asp.net Mvc_Jqgrid - Fatal编程技术网

Javascript jqGrid:为什么不';我为网格编辑触发定义的事件是什么?

Javascript jqGrid:为什么不';我为网格编辑触发定义的事件是什么?,javascript,jquery,asp.net-mvc,jqgrid,Javascript,Jquery,Asp.net Mvc,Jqgrid,我正在网格上进行在线编辑,但似乎无法触发任何与该编辑相关的事件 这里有afterSubmit:我希望它在用户编辑网格中的Quantity字段后激发,但它从不激发 $('#tblLines').jqGrid({ url: createUrl('/CRA/GetLines/'), editurl: '/CRA/EditModifyLine', emptyrecords: '', datatype: 'json', mty

我正在网格上进行在线编辑,但似乎无法触发任何与该编辑相关的事件

这里有afterSubmit:我希望它在用户编辑网格中的Quantity字段后激发,但它从不激发

$('#tblLines').jqGrid({
        url: createUrl('/CRA/GetLines/'),
        editurl: '/CRA/EditModifyLine',
        emptyrecords: '',
        datatype: 'json',
        mtype: 'GET',
        colNames: ['Group', 'Description', 'Quantity'],
        colModel: [
      { name: 'Group', index: 'Group', width: 100, align: 'left' },
      { name: 'Description', index: 'Description', width: 400, align: 'left' },
      { name: 'Quantity', index: 'Quantity', width: 150, align: 'left', editable: true },
        pager: jQuery('#pgrLines'),
        rowNum: 10,
        rowList: [5, 10, 20, 50],
        sortname: 'Group',
        sortorder: "desc",
        viewrecords: true,
        caption: 'Core Group Lines',
        onSelectRow: function(id) {
            $('#tblCoreGroupLines').editRow(id, true);
            lastsel = id;
        },
        afterSubmit: function(response, postdata) {
            alert('got here');
        },
        postData: { craId: $('#CraId').val() }
    });
我已经尝试将事件定义为navControl的一部分,但这也不起作用。在线编辑工作得很好——帖子成功了,结果又回来了,只是从来没有点击过应该关联到它的事件。我尝试了所有与数量字段的更改相关的事件,但没有一个有效


我是否在正确的位置定义了事件?我是否缺少网格上的属性或其他内容?

我认为您需要将properties参数中的
afterSubmit
传递到
editRow

因此,您需要像这样移动
afterSubmit

 .....
 onSelectRow: function(id) {
     $('#tblCoreGroupLines').editGridRow(id, { afterSubmit: function(response, postdata) {
           alert('got here');
        } 
     });
     lastsel = id;
},
...
在这方面,这些文件提供了很多帮助

上面的示例将导致一个模态(因为这是使用afterSubmit的唯一点)。如果您想在使用indline编辑成功更新后执行某些操作,您应该能够在OnSetrow内部执行以下操作

 $('#tblCoreGroupLines').editGridRow(id,true, undefined, function(res) { 
    // res is the response object from the $.ajax call
    alert('success!!') 
 } ); 
下面是js/grid.inlineedit.js中editRow的方法签名

    editRow : function(rowid,keys,oneditfunc,succesfunc, url, extraparam, aftesarvefunc,errorfunc, afterrestorefunc) {

您还可以使用editRow方法中的aftersavefunc事件来获取服务器响应,如果这是您要查找的唯一内容。

我认为您的做法是正确的。但是,该editRow语句过去有两个参数。editRow(id,true)。布尔“true”参数发生了什么变化?没有它,手机似乎无法提交。我希望避免弹出框。理想情况下,您希望在网格中获得内联编辑的行为。欢迎您。奇怪的是,内联和表单的方法SIG如此不同。