如何通过附加POSTDATA到一个附加录音功能 - jqGrid的 - MVC。净 [英] How to pass additional postdata into an add record function - JQGrid - MVC . NET

查看:470
本文介绍了如何通过附加POSTDATA到一个附加录音功能 - jqGrid的 - MVC。净的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的一个MVC项目jqGrid的插件。我试图避免使用会话。我已经能够通过额外POSTDATA到我的编辑和删除的功能,使用从jqGrid的的serializedata方法。

I am using the JQGrid plugin on an MVC project. I am trying to avoid using 'Session'. I have been able to pass extra postdata into my edit and delete functions, using the serializedata methods from JQGrid.

例如。

serializeEditData: function (postdata) 
{
    var rowdata = jQuery('#gridId').getRowData(postdata.id);
    return {id: postdata.id, oper: postdata.oper, SomeExtraData: $('#extradata').val()};
}

然而,似乎没有成为一个serializeAddData函数。是否有另一种方式改变后的数据为add方法发送之前?

However, there doesn't appear to be a serializeAddData function. Is there another way to alter the post data for the add method before it is sent?

推荐答案

一种方法 editGridRow 其实现形式编辑对于两个编辑和添加对话框。所以相同的事件han`ler <一href="http://www.trirand.com/jqgridwiki/doku.php?id=wiki%3aform_editing#events">serializeEditData可以在两种情况下使用。例如,

There are one method editGridRow which implement form editing for both "Edit" and "Add" dialogs. So the same event han`ler serializeEditData can be used in both cases. For example,

$("#list").jqGrid('navGrid','#pager',
    {/*navGrid options*/},
    {/*edit options*/
        serializeEditData: function (postdata) {
            // your implementation of serializeEditData for edit
        }
    },
    {/*add options*/
        serializeEditData: function (postdata) {
            // your implementation of serializeEditData for add
        }
    },
    {/*del options*/},
    {/*search options*/}

/);

通常 serializeEditData 事件,如果你需要转换的所有已发布数据的另一种格式,例如使JSON序列化是非常实用的。为了能够通过您可以使用 editData 参数,而不是额外的POSTDATA参数,具有相同的含义一样jqGrid的的 POSTDATA 参数

Typically serializeEditData event is very practical if you need convert all the posted data in another format, for example to make JSON serialization. To be able to pass extra postdata parameters you can use editData parameter instead which has the same meaning like postData parameter of jqGrid:

$("#list").jqGrid('navGrid','#pager',
    {/*navGrid options*/},
    {/*edit options*/
     editData: {SomeExtraData: $('#extradata').val()}
    },
    {/*add options*/
     editData: {SomeExtraData: $('#extradata').val()}
    },
    {/*del options*/},
    {/*search options*/}
);

或以这种方式更好(见<一href="http://stackoverflow.com/questions/2928371/how-to-filter-the-jqgrid-data-not-using-the-built-in-search-filter-box/2928819#2928819">this回答有关的功能的用法的财产 POSTDATA ):

or better in this way (see this answer about the usage of functions as the property of postData):

$("#list").jqGrid('navGrid','#pager',
    {/*navGrid options*/},
    {/*edit options*/
     editData: {SomeExtraData: function() {return $('#extradata').val();}}
    },
    {/*add options*/
     editData: {SomeExtraData: function() {return $('#extradata').val();}}
    },
    {/*del options*/},
    {/*search options*/}
);

这篇关于如何通过附加POSTDATA到一个附加录音功能 - jqGrid的 - MVC。净的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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