如何将其他postdata传递给添加记录函数 – JQGrid – MVC。 净
我在MVC项目上使用JQGrid插件。 我试图避免使用’Session’。 我已经能够使用JQGrid中的serializedata方法将额外的postdata传递到我的编辑和删除函数中。
例如
serializeEditData: function (postdata) { var rowdata = jQuery('#gridId').getRowData(postdata.id); return {id: postdata.id, oper: postdata.oper, SomeExtraData: $('#extradata').val()}; }
但是,似乎没有serializeAddData函数。 是否有另一种方法可以在发送之前更改add方法的post数据?
有一种方法 editGridRow ,它为“编辑”和“添加”对话框实现表单编辑。 因此,在两种情况下都可以使用相同的事件han`ler serializeEditData 。 例如,
$("#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*/}
/);
通常,如果您需要以其他格式转换所有发布的数据(例如,进行JSON序列化),则serializeEditData
事件非常实用。 为了能够传递额外的postdata参数,您可以使用editData
参数,它具有与postData
参数相同的含义:
$("#list").jqGrid('navGrid','#pager', {/*navGrid options*/}, {/*edit options*/ editData: {SomeExtraData: $('#extradata').val()} }, {/*add options*/ editData: {SomeExtraData: $('#extradata').val()} }, {/*del options*/}, {/*search options*/} );
或者这样更好(请参阅这个关于函数用法作为postData
属性的postData
):
上述就是C#学习教程:如何将其他postdata传递给添加记录函数 – JQGrid – MVC。 净分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!
$("#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*/} );
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/cdevelopment/1030789.html