jqGrid的:为什么不是我一格编辑射击定义的事件? [英] jqGrid: Why aren't the events that I defined for a grid edit firing?

查看:204
本文介绍了jqGrid的:为什么不是我一格编辑射击定义的事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在做在线编辑网格上,但似乎无法得到任何事件,火灾,将被捆绑到了编辑。

I'm doing in-line edits on a grid, but can't seem to get any events to fire that would be tied to that edit.

在这里,我有afterSubmit:我希望它激发用户编辑的数量字段中网后,但它永远不会触发

Here I have afterSubmit: and I want it to fire after the user has edited the Quantity field in the grid, but it never fires.

$('#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的一部分较低,但这并不能工作。该在线编辑工作正常 - 开机自检成功,结果回来,只是从来没有碰到,应该把它捆起来的事件。我已经尝试了所有将绑数量字段的变化的事件,但他们没有工作。

I've tried defining the events lower as part of a navControl, but that doesn't work either. The in-line edit works fine -- the POST succeeds and the result comes back, it just never hits the events that should be tied to it. I've tried all the events that would tie to the changing of the Quantity field, but none of them work.

我是否定义在正确的位置的情况下?我缺少对电网或什么属性?

Have I defined the event in the correct place? Am I missing a property on the grid or something?

推荐答案

我认为你需要在 afterSubmit 的属性参数传递给 editRow

I think you need to pass in the afterSubmit in the properties argument to editRow.

因此​​,你需要移动 afterSubmit 像这样:

Thus, you need to move the afterSubmit like so:

 .....
 onSelectRow: function(id) {
     $('#tblCoreGroupLines').editGridRow(id, { afterSubmit: function(response, postdata) {
           alert('got here');
        } 
     });
     lastsel = id;
},
...

了解 editGridRow 在这方面怎样的帮助该文档。

The docs about editGridRow kind of help in this regard.

以上样本将导致一个模式虽然(因为这是在使用afterSubmit的唯一场所。)如果你想使用indline编辑为成功更新之后做一些事情,你应该能够做到onSelectRow以下内

The above sample will cause a modal though (as that's the only spot where afterSubmit is used). If you want to do something after a successful update using an indline edit, you should be able to do the following inside of onSelectRow

 $('#tblCoreGroupLines').editGridRow(id,true, undefined, function(res) { 
    // res is the response object from the $.ajax call
    alert('success!!') 
 } );

下面是editRow方法签名从JS / grid.inlineedit.js

Here's the method signature for editRow from js/grid.inlineedit.js

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

这篇关于jqGrid的:为什么不是我一格编辑射击定义的事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆