jqgrid addRow saveRow beforeSend [英] jqgrid addRow saveRow beforeSend

查看:281
本文介绍了jqgrid addRow saveRow beforeSend的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个jqGrid,我向用户可以编辑的行添加了新行.他们有一个按钮来保存新行.我需要先使用ajax beforeSend才能在调用中添加一些安全性.在网格的其他几种情况下,这是可行的,但不是这种情况.不知道发生了什么.

I have a jqGrid that I am adding a new row to that the user can edit. They have a button to save the new row. I need to get to the ajax beforeSend to stuff some security into the call. This is working in several other scenarios with the grid, but, not this one. Not sure what is going on.

这是我添加新行的方式:

Here is how I am adding the new row:

  jQuery("#myTable").jqGrid('addRow',{
      rowID : "new_row",
      initdata : {},
      position :"first",
      useDefValues : false,
      useFormatter : false,
      addRowParams : {extraparam:{}});

这是我通过保存"按钮执行的代码:

Here is my the code executed by my save button:

      jQuery("#myTable").jqGrid('saveRow',"new_row", {
          "url": "{{path('recording_create')}}",
          "mtype": "POST",
          "succesfunc": function(response) {
              return true; 
          }
      });

我尝试了这个,但是没有被解雇.我以为保存行时会调用它:

I tried this, but, it is not fired. I thought this would be called when saving a row:

$.extend($.jgrid.defaults,                 
                {
                ajaxRowOptions: { 
                    beforeSend: function () {
                        alert('Before Row Send'); // not called
                     }
                    },
                }
            );

我也尝试过这种方法,但是,我认为这仅在表单编辑中需要吗?

I also tried this, but, I think this is only called on form editing?

            $.extend($.jgrid.edit, {
                ajaxEditOptions: {
                    beforeSend: function (jqXHR, settings) {
                        alert('Before Row Send');  // not called
}}});

有什么想法吗?

谢谢, 斯科特

推荐答案

您可以尝试使用

$.extend($.jgrid.inlineEdit, {
    ajaxRowOptions: {
        beforeSend: function (jqXHR, settings) {
            alert('Before Row Send');
        }
    }
});

我希望它能起作用.

已更新:很抱歉,但是正确的代码

UPDATED: Sorry, but the correct code

$.extend($.jgrid.defaults, {
    ajaxRowOptions: {
        beforeSend: function () {
            alert('Before Row Send');
        }
    }
});

您已经包含在问题文本中.它应该工作.仅在创建网格之前 验证代码是否执行很重要.

you already included in the text of your question. It should work. It's important only to verify that the code will be executed before the grid is created.

这篇关于jqgrid addRow saveRow beforeSend的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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